From 368bb348119f5442e14192c052b6639dc44786cc Mon Sep 17 00:00:00 2001 From: eight Date: Sun, 15 Oct 2017 05:19:22 +0800 Subject: [PATCH] Fix: make updateLinter wait linterConfig to load --- edit/lint.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/edit/lint.js b/edit/lint.js index 9e2c9ee6..d4298b8f 100644 --- a/edit/lint.js +++ b/edit/lint.js @@ -130,6 +130,13 @@ var linterConfig = { } }, 2000); }, + + init() { + if (!linterConfig.init.pending) { + linterConfig.init.pending = linterConfig.loadAll(); + } + return linterConfig.init.pending; + } }; function initLint() { @@ -143,7 +150,7 @@ function initLint() { $('#lint h2').addEventListener('click', toggleLintReport); } - linterConfig.loadAll().then(updateLinter); + updateLinter(); linterConfig.watchStorage(); prefs.subscribe(['editor.linter'], updateLinter); } @@ -155,7 +162,8 @@ function updateLinter({immediately, linter = prefs.get('editor.linter')} = {}) { } const GUTTERS_CLASS = 'CodeMirror-lint-markers'; - loadLinterAssets(linter).then(updateEditors); + Promise.all([linterConfig.init(), loadLinterAssets(linter)]) + .then(updateEditors); $('#linter-settings').style.display = !linter ? 'none' : 'inline-block'; $('#lint').style.display = 'none';