From 0f2425bbbde2b9aaf683908ec94929d40b504ecb Mon Sep 17 00:00:00 2001 From: Ian Yong Date: Sat, 2 Sep 2023 21:53:49 +0800 Subject: [PATCH] Fix breakpoints state going out of sync --- src/commons/editor/Editor.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/commons/editor/Editor.tsx b/src/commons/editor/Editor.tsx index 1f98406b2e..669c98f4fd 100644 --- a/src/commons/editor/Editor.tsx +++ b/src/commons/editor/Editor.tsx @@ -411,10 +411,7 @@ const EditorBase = React.memo((props: EditorProps & LocalStateProps) => { // hopelessly incomplete editor.on( 'gutterclick' as any, - makeHandleGutterClick( - (...args) => handleEditorUpdateBreakpointsRef.current(...args), - props.editorTabIndex - ) as any + makeHandleGutterClick(handleEditorUpdateBreakpointsRef.current, props.editorTabIndex) ); // Change all info annotations to error annotations @@ -485,8 +482,16 @@ const EditorBase = React.memo((props: EditorProps & LocalStateProps) => { if (!reactAceRef.current) { return; } - handleEditorValueChange(props.editorTabIndex, newCode); + shiftBreakpointsWithCode(reactAceRef.current.editor, delta); + + // Write editor state for the active editor tab to the store. + handleEditorValueChange(props.editorTabIndex, newCode); + handleEditorUpdateBreakpointsRef.current( + props.editorTabIndex, + reactAceRef.current.editor.session.getBreakpoints() + ); + if (handleUpdateHasUnsavedChanges) { handleUpdateHasUnsavedChanges(true); }