From e56eac7508b08de3ba0358da45cf0585c6e505e4 Mon Sep 17 00:00:00 2001 From: friebetill Date: Wed, 15 Feb 2023 21:45:30 +0800 Subject: [PATCH] Improve UX by opening in active leaf --- src/main.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main.ts b/src/main.ts index 03bac4a..12abaad 100644 --- a/src/main.ts +++ b/src/main.ts @@ -63,15 +63,17 @@ export default class FileDiffPlugin extends Plugin { } // Open differences view - const workspaceLeaf = this.app.workspace.getLeaf() - await workspaceLeaf.open( - new DifferencesView({ - leaf: workspaceLeaf, - file1: activeFile, - file2: compareFile, - showMergeOption: true, - }) - ) + const workspaceLeaf = this.app.workspace.getMostRecentLeaf() + if (workspaceLeaf != null) { + await workspaceLeaf.open( + new DifferencesView({ + leaf: workspaceLeaf, + file1: activeFile, + file2: compareFile, + showMergeOption: true, + }) + ) + } }, }) }