fix: RangeError: Position -1 out of range

This commit is contained in:
Tom Moor committed 2023-10-17 18:20:57 -04:00
1 parent 03869784be
commit ea97963feb
1 file changed
+6 -3
+6 -3
View File
@@ -186,9 +186,12 @@ function SuggestionsMenu<T extends MenuItem>(props: Props<T>) {
dispatch(
state.tr.insertText(
"",
state.selection.from -
(props.search ?? "").length -
(trimTrigger ? props.trigger.length : 0),
Math.max(
0,
state.selection.from -
(props.search ?? "").length -
(trimTrigger ? props.trigger.length : 0)
),
state.selection.to
)
);