From d061ab4803c550e470ff653e587927d7c8ce422e Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Thu, 6 Mar 2025 16:32:57 +0100 Subject: [PATCH] Handle some errors when user tries to open unified view while already open --- .../unified-diff-view.tsx | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/views/conflicts-resolution/unified-diff-view.tsx b/src/views/conflicts-resolution/unified-diff-view.tsx index 12c7619..6af98d6 100644 --- a/src/views/conflicts-resolution/unified-diff-view.tsx +++ b/src/views/conflicts-resolution/unified-diff-view.tsx @@ -239,34 +239,36 @@ const UnifiedDiffView: React.FC = ({ initialNewText, diffChunks, ); - const conflictRangesField = createRangesStateField(lineRanges); - const extensions = [ - conflictRangesField, - createDecorationsExtension(conflictRangesField), - EditorView.editable.of(true), - EditorView.theme({ - "&": { - backgroundColor: "var(--background-primary)", - color: "var(--text-normal)", - }, - ".cm-content": { - padding: 0, - caretColor: "var(--caret-color)", - fontSize: "var(--font-text-size)", - fontFamily: "var(--font-text)", - }, - "&.cm-focused .cm-selectionBackground, .cm-selectionBackground": { - background: "var(--text-selection)", - }, - "&.cm-focused": { - outline: 0, - }, - "&.cm-focused .cm-cursor": { - borderLeftColor: "var(--text-normal)", - }, - }), - ]; + const extensions = React.useMemo(() => { + const conflictRangesField = createRangesStateField(lineRanges); + return [ + conflictRangesField, + createDecorationsExtension(conflictRangesField), + EditorView.editable.of(true), + EditorView.theme({ + "&": { + backgroundColor: "var(--background-primary)", + color: "var(--text-normal)", + }, + ".cm-content": { + padding: 0, + caretColor: "var(--caret-color)", + fontSize: "var(--font-text-size)", + fontFamily: "var(--font-text)", + }, + "&.cm-focused .cm-selectionBackground, .cm-selectionBackground": { + background: "var(--text-selection)", + }, + "&.cm-focused": { + outline: 0, + }, + "&.cm-focused .cm-cursor": { + borderLeftColor: "var(--text-normal)", + }, + }), + ]; + }, [initialOldText, initialNewText]); return (