From 9c60e3152b6c9d2d5bfc366efbc1e9791385daac Mon Sep 17 00:00:00 2001 From: Tony Grosinger Date: Wed, 19 Jan 2022 19:04:33 -0800 Subject: [PATCH] Fix null pointer when handling key press in legacy editor Fixes #161 --- src/main.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index a62d4af..e335725 100644 --- a/src/main.ts +++ b/src/main.ts @@ -349,9 +349,11 @@ export default class TableEditorPlugin extends Plugin { ): void => { if (['Tab', 'Enter'].contains(event.key)) { let editor: Editor; + let view: MarkdownView; const activeLeaf = this.app.workspace.activeLeaf; if (activeLeaf.view instanceof MarkdownView) { editor = activeLeaf.view.editor; + view = activeLeaf.view; } const action = this.newPerformTableAction((te: TableEditor) => { @@ -385,8 +387,8 @@ export default class TableEditorPlugin extends Plugin { }, false); // Check first if we are in a table, if so, then execute. - if (action(true, editor, null)) { - action(false, editor, null); + if (action(true, editor, view)) { + action(false, editor, view); } } };