debounce and subscribe updateLinter
This commit is contained in:
parent
b91324992d
commit
3d5383ceaf
|
@ -371,9 +371,6 @@ function acmeEventListener(event) {
|
||||||
}
|
}
|
||||||
option = 'highlightSelectionMatches';
|
option = 'highlightSelectionMatches';
|
||||||
break;
|
break;
|
||||||
case 'linter':
|
|
||||||
debounce(updateLinter);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
CodeMirror.setOption(option, value);
|
CodeMirror.setOption(option, value);
|
||||||
}
|
}
|
||||||
|
|
15
edit/lint.js
15
edit/lint.js
|
@ -93,7 +93,7 @@ var linterConfig = {
|
||||||
if (area === 'sync') {
|
if (area === 'sync') {
|
||||||
for (const name of ['editorCSSLintConfig', 'editorStylelintConfig']) {
|
for (const name of ['editorCSSLintConfig', 'editorStylelintConfig']) {
|
||||||
if (name in changes && changes[name].newValue !== changes[name].oldValue) {
|
if (name in changes && changes[name].newValue !== changes[name].oldValue) {
|
||||||
this.loadAll().then(() => debounce(updateLinter));
|
this.loadAll().then(updateLinter);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,9 +132,16 @@ function initLint() {
|
||||||
|
|
||||||
linterConfig.loadAll();
|
linterConfig.loadAll();
|
||||||
linterConfig.watchStorage();
|
linterConfig.watchStorage();
|
||||||
|
prefs.subscribe(updateLinter, ['editor.linter']);
|
||||||
|
updateLinter();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLinter(linter = prefs.get('editor.linter')) {
|
function updateLinter({immediately} = {}) {
|
||||||
|
if (!immediately) {
|
||||||
|
debounce(updateLinter, 0, {immediately: true});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const linter = prefs.get('editor.linter');
|
||||||
const GUTTERS_CLASS = 'CodeMirror-lint-markers';
|
const GUTTERS_CLASS = 'CodeMirror-lint-markers';
|
||||||
|
|
||||||
function updateEditors() {
|
function updateEditors() {
|
||||||
|
@ -147,7 +154,7 @@ function updateLinter(linter = prefs.get('editor.linter')) {
|
||||||
updateGutters(cm, guttersOption);
|
updateGutters(cm, guttersOption);
|
||||||
}
|
}
|
||||||
cm.refresh();
|
cm.refresh();
|
||||||
updateLintReport(cm, 200);
|
updateLintReport(cm);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +415,7 @@ function setupLinterSettingsEvents(popup) {
|
||||||
}
|
}
|
||||||
linterConfig.save(json);
|
linterConfig.save(json);
|
||||||
linterConfig.showSavedMessage();
|
linterConfig.showSavedMessage();
|
||||||
debounce(updateLinter);
|
updateLinter();
|
||||||
} else {
|
} else {
|
||||||
showLinterErrorMessage(linter, t('linterJSONError'));
|
showLinterErrorMessage(linter, t('linterJSONError'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user