From 547f429af4c831b9e0ea1fdad56d42c143242c2c Mon Sep 17 00:00:00 2001 From: Vanessa Sochat Date: Thu, 9 Jan 2020 09:24:01 -0700 Subject: [PATCH] adding check for active editor Signed-off-by: Vanessa Sochat --- lib/main.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 067c9e5..3eee2c8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,10 +33,12 @@ let SRecipe = { // This is the main entry function called on the event trigger setGrammar() { let editor = atom.workspace.getActiveTextEditor(); - let buffer = editor.getBuffer() - if (editor.getTitle().startsWith('Singularity.') - && editor.getGrammar().scopeName == "text.plain.null-grammar") { - atom.grammars.assignLanguageMode(buffer, grammarName) + if (editor) { + let buffer = editor.getBuffer() + if (editor.getTitle().startsWith('Singularity.') + && editor.getGrammar().scopeName == "text.plain.null-grammar") { + atom.grammars.assignLanguageMode(buffer, grammarName) + } } } };