report line:ch in live-preview errors for usercss

This commit is contained in:
tophf 2018-03-11 16:47:27 +03:00
parent 66704a78b3
commit dbba338229
2 changed files with 6 additions and 2 deletions

View File

@ -623,6 +623,10 @@ onDOMscriptReady('/codemirror.js').then(() => {
}).then(() => {
errors.classList.add('hidden');
}).catch(err => {
if (err && editor && !Number.isNaN(err.index)) {
const pos = editors[0].posFromIndex(err.index);
err = `${pos.line}:${pos.ch} ${err}`;
}
errors.classList.remove('hidden');
errors.onclick = () => messageBox.alert(String(err), 'pre');
});

View File

@ -450,8 +450,8 @@ var usercss = (() => {
try {
doParse();
} catch (e) {
// grab additional info
e.index = metaIndex;
// the source code string offset
e.index = metaIndex + state.re.lastIndex;
throw e;
}