show lint report on open earlier

This commit is contained in:
tophf 2017-08-29 23:36:56 +03:00
parent 05e0e7004b
commit 854bdea61e
2 changed files with 15 additions and 8 deletions

View File

@ -1257,7 +1257,6 @@ function initWithStyle({style, codeIsUpdated}) {
updateTitle(); updateTitle();
return; return;
} }
// if this was done in response to an update, we need to clear existing sections // if this was done in response to an update, we need to clear existing sections
getSections().forEach(div => { div.remove(); }); getSections().forEach(div => { div.remove(); });
const queue = style.sections.length ? style.sections.slice() : [{code: ''}]; const queue = style.sections.length ? style.sections.slice() : [{code: ''}];
@ -1278,11 +1277,18 @@ function initWithStyle({style, codeIsUpdated}) {
const sectionDiv = addSection(null, queue.shift()); const sectionDiv = addSection(null, queue.shift());
maximizeCodeHeight(sectionDiv, !queue.length); maximizeCodeHeight(sectionDiv, !queue.length);
const cm = sectionDiv.CodeMirror; const cm = sectionDiv.CodeMirror;
if (CodeMirror.lint) { if (prefs.get('editor.linter')) {
setTimeout(() => { setTimeout(() => {
cm.setOption('lint', CodeMirror.defaults.lint); cm.setOption('lint', linterConfig.getForCodeMirror());
updateLintReport(cm, 0); updateLintReport(cm, 100);
}, prefs.get('editor.lintDelay')); if (!queue.length) {
setTimeout(() => {
const state = cm.state.lint || {};
clearTimeout(state.renderTimeout);
renderLintReport();
}, 100);
}
});
} }
} }
} }

View File

@ -191,15 +191,16 @@ function updateLinter({immediately} = {}) {
} }
function updateLintReport(cm, delay) { function updateLintReport(cm, delay) {
const state = cm.state.lint || {};
if (delay === 0) { if (delay === 0) {
// immediately show pending csslint/stylelint messages in onbeforeunload and save // immediately show pending csslint/stylelint messages in onbeforeunload and save
clearTimeout(state.lintTimeout);
update(cm); update(cm);
return; return;
} }
const state = cm.state.lint;
if (delay > 0) { if (delay > 0) {
clearTimeout((state || {}).lintTimeout); clearTimeout(state.lintTimeout);
(state || {}).lintTimeout = setTimeout(cm => { state.lintTimeout = setTimeout(cm => {
// the temp monkeypatch only allows sep=false that returns a line array // the temp monkeypatch only allows sep=false that returns a line array
// because during editing this is what we need, not the combined text // because during editing this is what we need, not the combined text
const _getValue = cm.getValue; const _getValue = cm.getValue;