Fix save template. Closes #607
This commit is contained in:
parent
30d00dbd3a
commit
8a3c260eb9
|
@ -230,21 +230,25 @@ function createSourceEditor({style, onTitleChanged}) {
|
||||||
.then(replaceStyle)
|
.then(replaceStyle)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
if (err.handled) return;
|
if (err.handled) return;
|
||||||
if (err.code === 'missingMandatory' && err.args.includes('name')) {
|
|
||||||
messageBox.confirm(t('usercssReplaceTemplateConfirmation')).then(ok => ok &&
|
|
||||||
chromeSync.setLZValue('usercssTemplate', code)
|
|
||||||
.then(() => chromeSync.getLZValue('usercssTemplate'))
|
|
||||||
.then(saved => saved !== code && messageBox.alert(t('syncStorageErrorSaving'))));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const contents = Array.isArray(err) ?
|
const contents = Array.isArray(err) ?
|
||||||
$create('pre', err.join('\n')) :
|
$create('pre', err.join('\n')) :
|
||||||
[err.message || String(err)];
|
[err.message || String(err)];
|
||||||
if (Number.isInteger(err.index)) {
|
if (Number.isInteger(err.index)) {
|
||||||
const pos = cm.posFromIndex(err.index);
|
const pos = cm.posFromIndex(err.index);
|
||||||
contents[0] += ` (line ${pos.line + 1} col ${pos.ch + 1})`;
|
const meta = drawLinePointer(pos);
|
||||||
contents.push($create('pre', drawLinePointer(pos)));
|
|
||||||
|
// save template
|
||||||
|
if (err.code === 'missingValue' && meta.includes('@name')) {
|
||||||
|
messageBox.confirm(t('usercssReplaceTemplateConfirmation')).then(ok => ok &&
|
||||||
|
chromeSync.setLZValue('usercssTemplate', code)
|
||||||
|
.then(() => chromeSync.getLZValue('usercssTemplate'))
|
||||||
|
.then(saved => saved !== code && messageBox.alert(t('syncStorageErrorSaving'))));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
contents[0] += ` (line ${pos.line + 1} col ${pos.ch + 1})`;
|
||||||
|
contents.push($create('pre', meta));
|
||||||
messageBox.alert(contents, 'pre');
|
messageBox.alert(contents, 'pre');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user