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, + }) + ) + } }, }) }