preserve dirty after importing moz-format, fixes #1075

This commit is contained in:
tophf 2020-10-22 23:18:58 +03:00
parent 6593d5c05a
commit 0199b2c0bb

View File

@ -48,7 +48,7 @@ function createSectionsEditor(editorBase) {
let sectionOrder = ''; let sectionOrder = '';
let headerOffset; // in compact mode the header is at the top so it reduces the available height let headerOffset; // in compact mode the header is at the top so it reduces the available height
const ready = initSections(style.sections.slice()); const ready = initSections(style.sections.slice(), {isFirstInit: true});
const livePreview = createLivePreview(); const livePreview = createLivePreview();
livePreview.show(Boolean(style.id)); livePreview.show(Boolean(style.id));
@ -450,10 +450,11 @@ function createSectionsEditor(editorBase) {
} }
function initSections(originalSections, { function initSections(originalSections, {
total = originalSections.length,
focusOn = 0, focusOn = 0,
isFirstInit,
} = {}) { } = {}) {
let done; let done;
const total = originalSections.length;
return new Promise(resolve => { return new Promise(resolve => {
done = resolve; done = resolve;
chunk(true); chunk(true);
@ -462,7 +463,7 @@ function createSectionsEditor(editorBase) {
const t0 = performance.now(); const t0 = performance.now();
while (originalSections.length && performance.now() - t0 < 100) { while (originalSections.length && performance.now() - t0 < 100) {
insertSectionAfter(originalSections.shift(), undefined, forceRefresh); insertSectionAfter(originalSections.shift(), undefined, forceRefresh);
dirty.clear(); if (isFirstInit) dirty.clear();
if (focusOn !== false && sections[focusOn]) { if (focusOn !== false && sections[focusOn]) {
sections[focusOn].cm.focus(); sections[focusOn].cm.focus();
focusOn = false; focusOn = false;