emphasize active rules in linter config dialog
This commit is contained in:
parent
2a4e55dfec
commit
596c87e0be
|
@ -823,6 +823,11 @@ body:not(.find-open) [data-match-highlight-count="1"] .CodeMirror-selection-high
|
||||||
#message-box.center.lint-config #message-box-contents {
|
#message-box.center.lint-config #message-box-contents {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
#help-popup .active-linter-rule {
|
||||||
|
font-weight: bold;
|
||||||
|
text-decoration: underline;
|
||||||
|
background-color: rgba(128, 128, 128, .2);
|
||||||
|
}
|
||||||
|
|
||||||
/************ CSS beautifier ************/
|
/************ CSS beautifier ************/
|
||||||
.beautify-options {
|
.beautify-options {
|
||||||
|
|
|
@ -57,6 +57,21 @@
|
||||||
]));
|
]));
|
||||||
cm = popup.codebox;
|
cm = popup.codebox;
|
||||||
cm.focus();
|
cm.focus();
|
||||||
|
const rulesStr = getActiveRules().join('|');
|
||||||
|
if (rulesStr) {
|
||||||
|
const rx = new RegExp(`"(${rulesStr})"\\s*:`);
|
||||||
|
let line = 0;
|
||||||
|
cm.startOperation();
|
||||||
|
cm.eachLine(({text}) => {
|
||||||
|
const m = rx.exec(text);
|
||||||
|
if (m) {
|
||||||
|
const ch = m.index + 1;
|
||||||
|
cm.markText({line, ch}, {line, ch: ch + m[1].length}, {className: 'active-linter-rule'});
|
||||||
|
}
|
||||||
|
++line;
|
||||||
|
});
|
||||||
|
cm.endOperation();
|
||||||
|
}
|
||||||
cm.on('changes', updateConfigButtons);
|
cm.on('changes', updateConfigButtons);
|
||||||
updateConfigButtons();
|
updateConfigButtons();
|
||||||
window.on('closeHelp', onConfigClose, {once: true});
|
window.on('closeHelp', onConfigClose, {once: true});
|
||||||
|
@ -86,15 +101,20 @@
|
||||||
rule === 'CssSyntaxError' ? rule : $createLink(baseUrl + rule, rule));
|
rule === 'CssSyntaxError' ? rule : $createLink(baseUrl + rule, rule));
|
||||||
}
|
}
|
||||||
const header = t('linterIssuesHelp', '\x01').split('\x01');
|
const header = t('linterIssuesHelp', '\x01').split('\x01');
|
||||||
const activeRules = new Set([...linterMan.getIssues()].map(issue => issue.rule));
|
|
||||||
helpPopup.show(t('linterIssues'),
|
helpPopup.show(t('linterIssues'),
|
||||||
$create([
|
$create([
|
||||||
header[0], headerLink, header[1],
|
header[0], headerLink, header[1],
|
||||||
$create('ul.rules', [...activeRules].map(template)),
|
$create('ul.rules', getActiveRules().map(template)),
|
||||||
$create('button', {onclick: linterMan.showLintConfig}, t('configureStyle')),
|
$create('button', {onclick: linterMan.showLintConfig}, t('configureStyle')),
|
||||||
]));
|
]));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getActiveRules() {
|
||||||
|
const all = [...linterMan.getIssues()].map(issue => issue.rule);
|
||||||
|
const uniq = new Set(all);
|
||||||
|
return [...uniq];
|
||||||
|
}
|
||||||
|
|
||||||
function getLexicalDepth(lexicalState) {
|
function getLexicalDepth(lexicalState) {
|
||||||
let depth = 0;
|
let depth = 0;
|
||||||
while ((lexicalState = lexicalState.prev)) {
|
while ((lexicalState = lexicalState.prev)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user