Add: unhook event
This commit is contained in:
parent
30fb084d4d
commit
5ec82adaf9
|
@ -2,17 +2,23 @@
|
||||||
|
|
||||||
var linter = (() => { // eslint-disable-line no-var
|
var linter = (() => { // eslint-disable-line no-var
|
||||||
const changeCallbacks = [];
|
const changeCallbacks = [];
|
||||||
|
const unhookCallbacks = [];
|
||||||
const linters = [];
|
const linters = [];
|
||||||
const cms = new Set();
|
const cms = new Set();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
register,
|
register,
|
||||||
refresh,
|
refresh,
|
||||||
onChange,
|
|
||||||
hook,
|
hook,
|
||||||
unhook
|
unhook,
|
||||||
|
onChange,
|
||||||
|
onUnhook
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function onUnhook(cb) {
|
||||||
|
unhookCallbacks.push(cb);
|
||||||
|
}
|
||||||
|
|
||||||
function onChange(cb) {
|
function onChange(cb) {
|
||||||
changeCallbacks.push(cb);
|
changeCallbacks.push(cb);
|
||||||
}
|
}
|
||||||
|
@ -31,6 +37,9 @@ var linter = (() => { // eslint-disable-line no-var
|
||||||
function unhook(cm) {
|
function unhook(cm) {
|
||||||
cm.setOption('lint', false);
|
cm.setOption('lint', false);
|
||||||
cms.delete(cm);
|
cms.delete(cm);
|
||||||
|
for (const cb of unhookCallbacks) {
|
||||||
|
cb(cm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function register(getAnnotations) {
|
function register(getAnnotations) {
|
||||||
|
@ -57,6 +66,7 @@ var linter = (() => { // eslint-disable-line no-var
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// FIXME: this should be put inside edit.js
|
||||||
prefs.subscribe(['editor.linter'], () => {
|
prefs.subscribe(['editor.linter'], () => {
|
||||||
linter.refresh();
|
linter.refresh();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user