Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
WardBrian committed Jul 30, 2024
1 parent 9fe0e40 commit 5957896
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gui/src/app/FileEditor/TextEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const TextEditor: FunctionComponent<Props> = ({

useEffect(() => {
if (!editorInstance) return;
editorInstance.addAction({
const disposable = editorInstance.addAction({
id: "save",
label: "Save",
keybindings: [KeyMod.CtrlCmd | KeyCode.KeyS],
Expand All @@ -113,14 +113,18 @@ const TextEditor: FunctionComponent<Props> = ({
}
},
});
return () => {
disposable.dispose();
};
}, [editorInstance, onSaveText, readOnly]);

useEffect(() => {
if (!editorInstance) return;
if (!actions) return;
for (const action of actions) {
editorInstance.addAction(action);
}
const disposables = actions.map(editorInstance.addAction);
return () => {
disposables.forEach((d) => d.dispose());
};
}, [actions, editorInstance]);

const edited = useMemo(() => {
Expand Down

0 comments on commit 5957896

Please sign in to comment.