fix(app): replace the whole +: token when picking a reaction emoji (#1916)

This commit is contained in:
Hampus
2026-08-24 12:45:02 +02:00
committed by GitHub
parent b1fb2c14a1
commit 9efd2b0a73
2 changed files with 6 additions and 2 deletions
@@ -28,6 +28,10 @@ export function getComposerAutocompleteReplacementStart(
if (type === 'commandArg') {
return Math.max(0, textUpToCursor.length - (matchedArgument == null ? 0 : matchedArgument.length));
}
if (type === 'emojiReaction') {
const whole = match[0] == null ? '' : match[0];
return Math.max(0, (match.index == null ? 0 : match.index) + (whole.length - whole.trimStart().length));
}
return Math.max(0, (match.index == null ? 0 : match.index) + (matchedPrefix == null ? 0 : matchedPrefix.length));
}
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {getComposerAutocompleteReplacementStart} from '@app/features/lexical/composer/ComposerAutocompleteInsertion';
import {detectAutocompleteTrigger} from '@app/features/messaging/utils/SlashCommandUtils';
import type {MenuTextMatch} from '@lexical/react/LexicalTypeaheadMenuPlugin';
@@ -8,8 +9,7 @@ export function buildComposerMenuMatch(fullText: string, anchorText: string): Me
if (trigger == null) {
return null;
}
const matchStart =
(trigger.match.index == null ? 0 : trigger.match.index) + (trigger.match[1] == null ? 0 : trigger.match[1].length);
const matchStart = getComposerAutocompleteReplacementStart(fullText, trigger.type, trigger.match);
const tokenLength = fullText.length - matchStart;
const leadOffset = Math.max(0, anchorText.length - tokenLength);
return {