Skip to content

Commit b9e904e

Browse files
authored
Clear breakpoints when following share links (#2370)
* Clear editor breakpoints when loading query string program * Update editor breakpoints display when prop updates
1 parent 9d2b17a commit b9e904e

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/commons/editor/Editor.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,14 @@ const EditorBase = React.memo((props: EditorProps & LocalStateProps) => {
335335
handlePromptAutocompleteRef.current = props.handlePromptAutocomplete;
336336
}, [props.handleEditorUpdateBreakpoints, props.handlePromptAutocomplete]);
337337

338+
React.useEffect(() => {
339+
const editor = reactAceRef.current?.editor;
340+
if (editor === undefined) {
341+
return;
342+
}
343+
displayBreakpoints(editor, props.breakpoints);
344+
}, [props.breakpoints]);
345+
338346
// Handles input into AceEditor causing app to scroll to the top on iOS Safari
339347
React.useEffect(() => {
340348
const isIOS = /iPhone|iPad|iPod/.test(navigator.userAgent);
@@ -443,7 +451,7 @@ const EditorBase = React.memo((props: EditorProps & LocalStateProps) => {
443451
}
444452
}
445453

446-
const { onChange, onLoad } = aceEditorProps;
454+
const { onChange } = aceEditorProps;
447455

448456
aceEditorProps.onChange = React.useCallback(
449457
(newCode: string, delta: Ace.Delta) => {
@@ -472,16 +480,6 @@ const EditorBase = React.memo((props: EditorProps & LocalStateProps) => {
472480
]
473481
);
474482

475-
aceEditorProps.onLoad = React.useCallback(
476-
(editor: IAceEditor) => {
477-
displayBreakpoints(editor, props.breakpoints);
478-
if (onLoad !== undefined) {
479-
onLoad(editor);
480-
}
481-
},
482-
[props.breakpoints, onLoad]
483-
);
484-
485483
aceEditorProps.commands = Object.entries(keyHandlers)
486484
.filter(([_, exec]) => exec)
487485
.map(([name, exec]) => ({ name, bindKey: keyBindings[name], exec: exec! }));

src/pages/playground/Playground.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export async function handleHash(hash: string, props: PlaygroundProps) {
184184
const program = programLz && decompressFromEncodedURIComponent(programLz);
185185
if (program) {
186186
props.handleEditorValueChange(program);
187+
props.handleEditorUpdateBreakpoints([]);
187188
}
188189
const variant: Variant =
189190
sourceLanguages.find(

0 commit comments

Comments
 (0)