Skip to content

Commit

Permalink
Track what extensions we have prompted for per editing session
Browse files Browse the repository at this point in the history
  • Loading branch information
confused-Techie committed Feb 3, 2024
1 parent 3a6c76b commit ac09e4f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/grammar-finder/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ const PackageListView = require("./package-list-view.js");
class GrammarFinder {
activate() {

// This local variable is intended to act as 'session' storage, or editing
// session storage. Where the next time the editor is opened it's info is gone
this.promptedForExt = [];

atom.grammars.emitter.on("did-auto-assign-grammar", async (data) => {
if (!atom.config.get("grammar-finder.autoFind")) {
// autofind is turned off
Expand All @@ -26,15 +30,22 @@ class GrammarFinder {
return;
}

if (this.promptedForExt.includes(ext)) {
// If we have already prompted for this extension in this editing session
return;
}

const packages = await this.checkForGrammars(ext);

if (packages.length === 0) {
// No packages were found that support this grammar
return;
}

this.promptedForExt.push(ext);

// Lets notify the user about the found packages
this.notify(packages, extOrFalse, "Pulsar couldn't identify an installed grammar for this file.");
this.notify(packages, ext, "Pulsar couldn't identify an installed grammar for this file.");
});

this.disposables = new CompositeDisposable();
Expand Down

0 comments on commit ac09e4f

Please sign in to comment.