From 68c3b4e6dff4c26ba1faef3dead156bd66f33ef5 Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Thu, 6 Mar 2025 17:37:00 +0100 Subject: [PATCH] Handle conflict resolution --- src/views/conflicts-resolution/mobile-app.tsx | 8 +++--- .../unified-diff-view.tsx | 25 +++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/views/conflicts-resolution/mobile-app.tsx b/src/views/conflicts-resolution/mobile-app.tsx index a613eb4..f5978d2 100644 --- a/src/views/conflicts-resolution/mobile-app.tsx +++ b/src/views/conflicts-resolution/mobile-app.tsx @@ -14,7 +14,7 @@ const MobileApp = ({ ConflictResolution[] >([]); - const onConflictResolved = (fileIndex: number) => { + const onConflictResolved = (fileIndex: number, content: string) => { // Remove the file from the conflicts to resolve const remainingFiles = files.filter((_, index) => index !== fileIndex); setFiles(remainingFiles); @@ -23,7 +23,7 @@ const MobileApp = ({ ...resolvedConflicts, { filePath: files[fileIndex].filePath, - content: files[fileIndex].localContent, + content, }, ]; setResolvedConflicts(newResolvedConflicts); @@ -57,7 +57,9 @@ const MobileApp = ({ onConflictResolved(index)} + onConflictResolved={(content: string) => { + onConflictResolved(index, content); + }} /> ); diff --git a/src/views/conflicts-resolution/unified-diff-view.tsx b/src/views/conflicts-resolution/unified-diff-view.tsx index 02e54b2..b424d87 100644 --- a/src/views/conflicts-resolution/unified-diff-view.tsx +++ b/src/views/conflicts-resolution/unified-diff-view.tsx @@ -7,7 +7,7 @@ import diff, { DiffChunk } from "./diff"; interface UnifiedDiffViewProps { initialOldText: string; initialNewText: string; - onConflictResolved: () => void; + onConflictResolved: (content: string) => void; } const createUnifiedDocument = ( @@ -219,6 +219,8 @@ const UnifiedDiffView: React.FC = ({ initialNewText, onConflictResolved, }) => { + const editorViewRef = React.useRef(null); + const diffChunks = diff(initialOldText, initialNewText); const { doc, lineRanges } = createUnifiedDocument( initialOldText, @@ -250,7 +252,8 @@ const UnifiedDiffView: React.FC = ({ "&": { backgroundColor: "var(--background-primary)", color: "var(--text-normal)", - border: "1px solid var(--background-modifier-border)", + borderTop: "1px solid var(--background-modifier-border)", + borderBottom: "1px solid var(--background-modifier-border)", }, ".cm-content": { padding: 0, @@ -288,6 +291,9 @@ const UnifiedDiffView: React.FC = ({ theme="none" basicSetup={false} extensions={extensions} + onCreateEditor={(view: EditorView) => { + editorViewRef.current = view; + }} />
= ({ }} >