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