Skip to content

Commit

Permalink
Merge pull request #808 from Dyalog/iss803
Browse files Browse the repository at this point in the history
Dispose old ac providers when switching prefix key
  • Loading branch information
e9gille authored Dec 13, 2021
2 parents f15825d + 5402d47 commit b0eb086
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/mon_apl.js
Original file line number Diff line number Diff line change
Expand Up @@ -993,31 +993,39 @@
},
};
D.Tokenizer = aplTokens;
const acProviders = [];
D.mop.then(() => {
const ml = monaco.languages;
ml.register({
id: 'apl',
extensions: ['.apl', '.apla', '.aplc', '.aplf', '.apli', '.apln', '.aplo',
'.mipage', '.dyapp', 'dyalog'],
});

ml.setTokensProvider('apl', aplTokens);
ml.setLanguageConfiguration('apl', aplConfig());
ml.registerCompletionItemProvider('apl', aplCompletions(D.prf.prefixKey()));
D.prf.prefixKey(x => ml.registerCompletionItemProvider('apl', aplCompletions(x)));
ml.registerHoverProvider('apl', aplHover);
ml.registerFoldingRangeProvider('apl', aplFold);
ml.registerDocumentFormattingEditProvider('apl', aplFormat);
ml.registerDocumentRangeFormattingEditProvider('apl', aplFormat);
ml.registerOnTypeFormattingEditProvider('apl', aplFormat);

ml.register({ id: 'apl-session' });
ml.setTokensProvider('apl-session', aplSessionTokens);
ml.setLanguageConfiguration('apl-session', aplSessionConfig);
ml.registerCompletionItemProvider('apl-session', aplCompletions(D.prf.prefixKey()));
D.prf.prefixKey(x => ml.registerCompletionItemProvider('apl-session', aplCompletions(x)));
ml.registerHoverProvider('apl-session', aplHover);
ml.registerDocumentFormattingEditProvider('apl-session', aplFormat);
ml.registerDocumentRangeFormattingEditProvider('apl-session', aplFormat);
ml.registerOnTypeFormattingEditProvider('apl-session', aplFormat);

const ac = aplCompletions(D.prf.prefixKey());
acProviders.push(ml.registerCompletionItemProvider('apl', ac));
acProviders.push(ml.registerCompletionItemProvider('apl-session', ac));
D.prf.prefixKey((x) => {
while (p = acProviders.pop()) p.dispose();
const ac = aplCompletions(x);
acProviders.push(ml.registerCompletionItemProvider('apl', ac));
acProviders.push(ml.registerCompletionItemProvider('apl-session', ac));
});
});
}

0 comments on commit b0eb086

Please sign in to comment.