From ea97963feb97a3b3ff7e41a412043cebd9054c2e Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 17 Oct 2023 18:20:57 -0400 Subject: [PATCH] fix: RangeError: Position -1 out of range --- app/editor/components/SuggestionsMenu.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/editor/components/SuggestionsMenu.tsx b/app/editor/components/SuggestionsMenu.tsx index 4c97f29cb..d311008e9 100644 --- a/app/editor/components/SuggestionsMenu.tsx +++ b/app/editor/components/SuggestionsMenu.tsx @@ -186,9 +186,12 @@ function SuggestionsMenu(props: Props) { 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 ) );