From 29766d2fe6f83c26f8076f21b30e8cc35bc57d0f Mon Sep 17 00:00:00 2001 From: bakuzan Date: Sat, 21 Jan 2023 09:02:05 +0000 Subject: [PATCH] Add null protection. I was getting "extension could not load error" on starting up obsidian. This was because of leaf not being its expected value. --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index c10d284..5cf97a8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -72,7 +72,7 @@ export default class BetterWordCount extends Plugin { giveEditorPlugin(leaf: WorkspaceLeaf): void { //@ts-expect-error, not typed - const editor = leaf.view.editor; + const editor = leaf?.view?.editor; if (editor) { const editorView = editor.cm as EditorView; const editorPlug = editorView.plugin(editorPlugin);