From 138286147f542be9b33318d23e50e6183db49731 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 23 Feb 2024 21:45:48 +0100 Subject: [PATCH] Fix emoji being inserted in incorrect places --- .../flavours/glitch/components/autosuggest_input.jsx | 6 +++--- .../flavours/glitch/components/autosuggest_textarea.jsx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/javascript/flavours/glitch/components/autosuggest_input.jsx b/app/javascript/flavours/glitch/components/autosuggest_input.jsx index 97da532ebb..f707a18e1d 100644 --- a/app/javascript/flavours/glitch/components/autosuggest_input.jsx +++ b/app/javascript/flavours/glitch/components/autosuggest_input.jsx @@ -15,8 +15,8 @@ import { AutosuggestHashtag } from './autosuggest_hashtag'; const textAtCursorMatchesToken = (str, caretPosition, searchTokens) => { let word; - let left = str.slice(0, caretPosition).search(/[^\s\u200B]+$/); - let right = str.slice(caretPosition).search(/[\s\u200B]/); + let left = str.slice(0, caretPosition).search(/\S+$/); + let right = str.slice(caretPosition).search(/\s/); if (right < 0) { word = str.slice(left); @@ -31,7 +31,7 @@ const textAtCursorMatchesToken = (str, caretPosition, searchTokens) => { word = word.trim().toLowerCase(); if (word.length > 0) { - return [left, word]; + return [left + 1, word]; } else { return [null, null]; } diff --git a/app/javascript/flavours/glitch/components/autosuggest_textarea.jsx b/app/javascript/flavours/glitch/components/autosuggest_textarea.jsx index 9fd199a21c..07fbccacc9 100644 --- a/app/javascript/flavours/glitch/components/autosuggest_textarea.jsx +++ b/app/javascript/flavours/glitch/components/autosuggest_textarea.jsx @@ -16,8 +16,8 @@ import { AutosuggestHashtag } from './autosuggest_hashtag'; const textAtCursorMatchesToken = (str, caretPosition) => { let word; - let left = str.slice(0, caretPosition).search(/[^\s\u200B]+$/); - let right = str.slice(caretPosition).search(/[\s\u200B]/); + let left = str.slice(0, caretPosition).search(/\S+$/); + let right = str.slice(caretPosition).search(/\s/); if (right < 0) { word = str.slice(left); @@ -32,7 +32,7 @@ const textAtCursorMatchesToken = (str, caretPosition) => { word = word.trim().toLowerCase(); if (word.length > 0) { - return [left, word]; + return [left + 1, word]; } else { return [null, null]; }