Skip to content

Commit 4eea558

Browse files
committed
fix: ensure previous leaf exists
Ensure that the previous leaf exists before switching to it.
1 parent 3bd8c2e commit 4eea558

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/generator.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ async function renderCM(
120120
const state = view.getState() as { mode: string };
121121
const container = document.body.createDiv();
122122

123-
app.workspace.setActiveLeaf(prevLeaf, { focus: true});
123+
if (prevLeaf instanceof WorkspaceLeaf) {
124+
app.workspace.setActiveLeaf(prevLeaf, { focus: true });
125+
}
124126

125127
if (state.mode != "preview") {
126128
await view.setState({ mode: "preview" }, { history: false });

0 commit comments

Comments
 (0)