From 99fc400bf5efe8ae7bafc303a1b088466e696105 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Sat, 18 Apr 2026 18:15:15 +0900 Subject: [PATCH 1/2] fix: detach diff models before disposal Co-authored-by: WillBooster (Codex CLI) --- src/DiffEditor/DiffEditor.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/DiffEditor/DiffEditor.tsx b/src/DiffEditor/DiffEditor.tsx index 6ac0ffc..4a92982 100644 --- a/src/DiffEditor/DiffEditor.tsx +++ b/src/DiffEditor/DiffEditor.tsx @@ -198,17 +198,23 @@ function DiffEditor({ }, [isMonacoMounting, isEditorReady, createEditor]); function disposeEditor(): void { - const models = editorRef.current?.getModel(); + const editor = editorRef.current; + const models = editor?.getModel(); - if (!keepCurrentOriginalModel) { + editor?.setModel(null); + editor?.dispose(); + + if (!keepCurrentOriginalModel && !models?.original.isDisposed()) { models?.original?.dispose(); } - if (!keepCurrentModifiedModel) { + if (!keepCurrentModifiedModel && !models?.modified.isDisposed()) { models?.modified?.dispose(); } - editorRef.current?.dispose(); + editorRef.current = null; + preventCreation.current = false; + setIsEditorReady(false); } return ( From c7c57f162522aa5b48517347a32265e9662d7215 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Sat, 18 Apr 2026 18:15:49 +0900 Subject: [PATCH 2/2] fix: address diff editor lint warnings Co-authored-by: WillBooster (Codex CLI) --- src/DiffEditor/DiffEditor.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/DiffEditor/DiffEditor.tsx b/src/DiffEditor/DiffEditor.tsx index 4a92982..1ef471c 100644 --- a/src/DiffEditor/DiffEditor.tsx +++ b/src/DiffEditor/DiffEditor.tsx @@ -194,13 +194,16 @@ function DiffEditor({ }, [isEditorReady]); useEffect(() => { - !isMonacoMounting && !isEditorReady && createEditor(); + if (!isMonacoMounting && !isEditorReady) { + createEditor(); + } }, [isMonacoMounting, isEditorReady, createEditor]); function disposeEditor(): void { const editor = editorRef.current; const models = editor?.getModel(); + // oxlint-disable-next-line unicorn/no-null -- Monaco detaches diff models with null. editor?.setModel(null); editor?.dispose(); @@ -212,6 +215,7 @@ function DiffEditor({ models?.modified?.dispose(); } + // oxlint-disable-next-line unicorn/no-null -- React refs use null after unmount. editorRef.current = null; preventCreation.current = false; setIsEditorReady(false);