Fix emoji being inserted in incorrect places

pull/2644/head
Claire 2024-02-23 21:45:48 +01:00
parent 6eede9d84b
commit 138286147f
2 changed files with 6 additions and 6 deletions

View File

@ -15,8 +15,8 @@ import { AutosuggestHashtag } from './autosuggest_hashtag';
const textAtCursorMatchesToken = (str, caretPosition, searchTokens) => { const textAtCursorMatchesToken = (str, caretPosition, searchTokens) => {
let word; let word;
let left = str.slice(0, caretPosition).search(/[^\s\u200B]+$/); let left = str.slice(0, caretPosition).search(/\S+$/);
let right = str.slice(caretPosition).search(/[\s\u200B]/); let right = str.slice(caretPosition).search(/\s/);
if (right < 0) { if (right < 0) {
word = str.slice(left); word = str.slice(left);
@ -31,7 +31,7 @@ const textAtCursorMatchesToken = (str, caretPosition, searchTokens) => {
word = word.trim().toLowerCase(); word = word.trim().toLowerCase();
if (word.length > 0) { if (word.length > 0) {
return [left, word]; return [left + 1, word];
} else { } else {
return [null, null]; return [null, null];
} }

View File

@ -16,8 +16,8 @@ import { AutosuggestHashtag } from './autosuggest_hashtag';
const textAtCursorMatchesToken = (str, caretPosition) => { const textAtCursorMatchesToken = (str, caretPosition) => {
let word; let word;
let left = str.slice(0, caretPosition).search(/[^\s\u200B]+$/); let left = str.slice(0, caretPosition).search(/\S+$/);
let right = str.slice(caretPosition).search(/[\s\u200B]/); let right = str.slice(caretPosition).search(/\s/);
if (right < 0) { if (right < 0) {
word = str.slice(left); word = str.slice(left);
@ -32,7 +32,7 @@ const textAtCursorMatchesToken = (str, caretPosition) => {
word = word.trim().toLowerCase(); word = word.trim().toLowerCase();
if (word.length > 0) { if (word.length > 0) {
return [left, word]; return [left + 1, word];
} else { } else {
return [null, null]; return [null, null];
} }