From a1fea0cb953b3a3c930e6b63dd32e9cefa0a4a7a Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Tue, 25 Feb 2025 18:50:12 +0100 Subject: [PATCH] Fix issue when rerendering conflict view --- src/views/conflicts-resolution/view.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/views/conflicts-resolution/view.tsx b/src/views/conflicts-resolution/view.tsx index a4aeb19..09459db 100644 --- a/src/views/conflicts-resolution/view.tsx +++ b/src/views/conflicts-resolution/view.tsx @@ -10,6 +10,7 @@ export const CONFLICTS_RESOLUTION_VIEW_TYPE = "conflicts-resolution-view"; export class ConflictsResolutionView extends ItemView { icon: IconName = "merge"; + private root: Root | null = null; constructor( leaf: WorkspaceLeaf, @@ -44,11 +45,13 @@ export class ConflictsResolutionView extends ItemView { } private render(conflicts: ConflictFile[]) { - const container = this.containerEl.children[1]; - container.empty(); - // We don't want any padding, the DiffView component will handle that - (container as HTMLElement).style.padding = "0"; - const root: Root = createRoot(container); + if (!this.root) { + const container = this.containerEl.children[1]; + container.empty(); + // We don't want any padding, the DiffView component will handle that + (container as HTMLElement).style.padding = "0"; + this.root = createRoot(container); + } const App = ({ initialFiles }: { initialFiles: ConflictFile[] }) => { const [files, setFiles] = React.useState(initialFiles); const [resolvedConflicts, setResolvedConflicts] = React.useState< @@ -149,7 +152,7 @@ export class ConflictsResolutionView extends ItemView { ); }; - root.render(); + this.root.render(); } async onClose() {