From 71f3dfbffd6605f5125d99f2f6fe88382d523fff Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 30 Nov 2017 20:42:52 +0300 Subject: [PATCH] usercss: don't relint on save; mode is an object once initialized --- edit/lint.js | 6 ++---- edit/source-editor.js | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/edit/lint.js b/edit/lint.js index ee35b94a..76f07bfb 100644 --- a/edit/lint.js +++ b/edit/lint.js @@ -32,10 +32,8 @@ var linterConfig = { getName() { // some dirty hacks to override editor.linter getting from prefs const linter = prefs.get('editor.linter'); - if (linter && editors[0] && editors[0].getOption('mode') !== 'css') { - return 'stylelint'; - } - return linter; + const mode = linter && editors[0] && editors[0].doc.mode; + return mode && mode !== 'css' && mode.name !== 'css' ? 'stylelint' : linter; }, getCurrent(linter = linterConfig.getName()) { diff --git a/edit/source-editor.js b/edit/source-editor.js index f2f07859..6aab98c7 100644 --- a/edit/source-editor.js +++ b/edit/source-editor.js @@ -59,10 +59,16 @@ function createSourceEditor(style) { function initLinterSwitch() { const linterEl = $('#editor.linter'); + let prevMode = NaN; cm.on('optionChange', (cm, option) => { if (option !== 'mode') { return; } + const mode = cm.doc.mode; + if (mode === prevMode || mode && mode.name === prevMode) { + return; + } + prevMode = mode; updateLinter(); update(); });