Skip to content

Commit

Permalink
Fix null pointer when handling key press in legacy editor
Browse files Browse the repository at this point in the history
Fixes #161
  • Loading branch information
tgrosinger committed Jan 20, 2022
1 parent 4b1b74a commit 9c60e31
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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);
}
}
};
Expand Down

0 comments on commit 9c60e31

Please sign in to comment.