Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 3989a1f

Browse files
author
Ryan Browne
committed
Revert "Use an improved regex that does not have have to iterate through the
entire string, and can just backtrack at most the last 2 characters." This regex is very efficient, but requires a specific form of the emoji shortcode that it is not clear is within our control. This is a restriction that is not required by the technicalities of solving the bug this PR is attempting to fix. (It requires that an emoji shortcode end with a colon.) This reverts commit 220cb0e. Signed-off-by: Ryan Browne <[email protected]>
1 parent 220cb0e commit 3989a1f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/autocomplete/EmojiProvider.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ function score(query, space) {
6464
}
6565

6666
function colonsTrimmed(str: string): string {
67-
// Trim off leading and potentially trailing `:` to correctly match the emoji shortcode names as they exist in emojibase.
68-
return str.replace(/^:(.*[^:]):?$/, "$1");
67+
// Trim off leading and potentially trailing `:` to correctly match the emoji data as they exist in emojibase.
68+
// Notes: The regex is pinned to the start and end of the string so that we can use the lazy-capturing `*?` matcher.
69+
// It needs to be lazy so that the trailing `:` is not captured in the replacement group, if it exists.
70+
return str.replace(/^:(.*?):?$/, "$1");
6971
}
7072

7173
export default class EmojiProvider extends AutocompleteProvider {

0 commit comments

Comments
 (0)