show lint report on open earlier
This commit is contained in:
parent
05e0e7004b
commit
854bdea61e
16
edit/edit.js
16
edit/edit.js
|
@ -1257,7 +1257,6 @@ function initWithStyle({style, codeIsUpdated}) {
|
|||
updateTitle();
|
||||
return;
|
||||
}
|
||||
|
||||
// if this was done in response to an update, we need to clear existing sections
|
||||
getSections().forEach(div => { div.remove(); });
|
||||
const queue = style.sections.length ? style.sections.slice() : [{code: ''}];
|
||||
|
@ -1278,11 +1277,18 @@ function initWithStyle({style, codeIsUpdated}) {
|
|||
const sectionDiv = addSection(null, queue.shift());
|
||||
maximizeCodeHeight(sectionDiv, !queue.length);
|
||||
const cm = sectionDiv.CodeMirror;
|
||||
if (CodeMirror.lint) {
|
||||
if (prefs.get('editor.linter')) {
|
||||
setTimeout(() => {
|
||||
cm.setOption('lint', CodeMirror.defaults.lint);
|
||||
updateLintReport(cm, 0);
|
||||
}, prefs.get('editor.lintDelay'));
|
||||
cm.setOption('lint', linterConfig.getForCodeMirror());
|
||||
updateLintReport(cm, 100);
|
||||
if (!queue.length) {
|
||||
setTimeout(() => {
|
||||
const state = cm.state.lint || {};
|
||||
clearTimeout(state.renderTimeout);
|
||||
renderLintReport();
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,15 +191,16 @@ function updateLinter({immediately} = {}) {
|
|||
}
|
||||
|
||||
function updateLintReport(cm, delay) {
|
||||
const state = cm.state.lint || {};
|
||||
if (delay === 0) {
|
||||
// immediately show pending csslint/stylelint messages in onbeforeunload and save
|
||||
clearTimeout(state.lintTimeout);
|
||||
update(cm);
|
||||
return;
|
||||
}
|
||||
const state = cm.state.lint;
|
||||
if (delay > 0) {
|
||||
clearTimeout((state || {}).lintTimeout);
|
||||
(state || {}).lintTimeout = setTimeout(cm => {
|
||||
clearTimeout(state.lintTimeout);
|
||||
state.lintTimeout = setTimeout(cm => {
|
||||
// the temp monkeypatch only allows sep=false that returns a line array
|
||||
// because during editing this is what we need, not the combined text
|
||||
const _getValue = cm.getValue;
|
||||
|
|
Loading…
Reference in New Issue
Block a user