diff --git a/edit/moz-section-finder.js b/edit/moz-section-finder.js index 9d143993..8b3afe72 100644 --- a/edit/moz-section-finder.js +++ b/edit/moz-section-finder.js @@ -142,12 +142,16 @@ function MozSectionFinder(cm) { } let op; let reusedAtStart = 0; + let reusedAtEnd = 0; const removed = sections.slice(cutAt, cutTo); for (const sec of added) { const i = removed.findIndex(isSameSection, sec); if (i >= 0) { - removed[i].funcs = sec.funcs; // use the new valueStart, valueEnd + const r = removed[i]; + r.funcs = sec.funcs; // use the new valueStart, valueEnd + sec.mark = r.mark; removed[i] = null; + reusedAtEnd++; if (!op) reusedAtStart++; } else { if (!op) op = cm.curOp || (cm.startOperation(), true); @@ -156,8 +160,11 @@ function MozSectionFinder(cm) { inclusiveRight: true, [KEY]: sec, }); + reusedAtEnd = 0; } } + added.length -= reusedAtEnd; + cutTo -= reusedAtEnd; if (reusedAtStart) { cutAt += reusedAtStart; added.splice(0, reusedAtStart); @@ -321,6 +328,10 @@ function MozSectionFinder(cm) { valueEnd: url.end, }); s = text.slice(ch, styles[j]).trim(); + if (s.includes('}')) { // a single `null` token like ` { } ` + goal = ''; + break; + } goal = s.startsWith(',') ? '_func' : s.startsWith('{') ? '_cmt' : !s && '_,'; // non-space something at this place = syntax error diff --git a/edit/moz-section-widget.js b/edit/moz-section-widget.js index fcb6fce5..f3a0b2fe 100644 --- a/edit/moz-section-widget.js +++ b/edit/moz-section-widget.js @@ -277,7 +277,7 @@ function MozSectionWidget( function renderWidget(sec, old) { let widget = old && old.widget; - const height = funcHeight * (sec.funcs.length || 1) || undefined; + const height = Math.round(funcHeight * (sec.funcs.length || 1)) || undefined; const node = renderContainer(sec, widget); if (widget) { widget.node = node;