From fddc8c47602e7462688df23e41c4185cb46a57cc Mon Sep 17 00:00:00 2001 From: confused-Techie Date: Thu, 1 Feb 2024 20:21:40 -0800 Subject: [PATCH] Add an event whenever a grammar is auto assigned that can be listened too --- src/grammar-registry.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/grammar-registry.js b/src/grammar-registry.js index 0a233c783..a0ce8997e 100644 --- a/src/grammar-registry.js +++ b/src/grammar-registry.js @@ -193,6 +193,10 @@ module.exports = class GrammarRegistry { buffer.getPath(), getGrammarSelectionContent(buffer) ); + + // Emit an event whenever a grammar is auto-assigned + this.emitter.emit("did-auto-assign-grammar", { grammar: result.grammar, buffer: buffer }); + this.languageOverridesByBufferId.delete(buffer.id); this.grammarScoresByBuffer.set(buffer, result.score); if (result.grammar !== buffer.getLanguageMode().grammar) {