diff options
author | Chenyu Huang <itschenyu@gmail.com> | 2025-07-24 15:58:24 -0700 |
---|---|---|
committer | Chenyu Huang <itschenyu@gmail.com> | 2025-07-24 15:58:24 -0700 |
commit | ead6862fc64597fdf811e0fb88e12ef0409b8d11 (patch) | |
tree | 7f2f0a42b540e105234e2df6cfc773fd014a7e7c /src/view/com/composer/text-input/TextInput.tsx | |
parent | fc2fae42bd8d90fd15b06c14a781efb79bc14e1d (diff) | |
download | voidsky-ead6862fc64597fdf811e0fb88e12ef0409b8d11.tar.zst |
fix some auto complete issues
Diffstat (limited to 'src/view/com/composer/text-input/TextInput.tsx')
-rw-r--r-- | src/view/com/composer/text-input/TextInput.tsx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/view/com/composer/text-input/TextInput.tsx b/src/view/com/composer/text-input/TextInput.tsx index e9c5d86b9..ea92d0b91 100644 --- a/src/view/com/composer/text-input/TextInput.tsx +++ b/src/view/com/composer/text-input/TextInput.tsx @@ -96,10 +96,11 @@ export const TextInput = forwardRef(function TextInputImpl( newRt.detectFacetsWithoutResolution() setRichText(newRt) - const prefix = getMentionAt( - newText, - textInputSelection.current?.start || 0, - ) + // NOTE: BinaryFiddler + // onChangeText happens before onSelectionChange, cursorPos is out of bound if the user deletes characters, + const cursorPos = textInputSelection.current?.start ?? 0 + const prefix = getMentionAt(newText, Math.min(cursorPos, newText.length)) + if (prefix) { setAutocompletePrefix(prefix.value) } else if (autocompletePrefix) { |