fix: redraw tab stops when the document is replaced
The measuring pass keeps the layout it last drew as a string key and skips the redraw when a pass measures the same again. Replacing the document maps every decoration away, so an identical layout has to be drawn again — the guard now compares the live decoration count as well. Two documents with the same tab layout otherwise left every tab on the default grid.
This commit is contained in:
1 parent
c115b11c8d
commit
b892accdd5
2 files changed
+6
-2
No files matched your search
@@ -439,7 +439,11 @@ export const TabStops = Extension.create({
|
||||
try { layout = measure(view); } catch { return; }
|
||||
const { widths, breaks } = layout;
|
||||
const next = widths.map((w) => `${w.pos}:${w.width}:${w.leader ?? ''}`).join(',') + `|${breaks.join(',')}`;
|
||||
if (next === key) return;
|
||||
// Replacing the document maps every decoration away, so a layout identical to
|
||||
// the last one — the two forms of one letter template — has to be dispatched
|
||||
// again rather than recognised as already applied.
|
||||
const live = tabStopsKey.getState(view.state)?.find().length ?? 0;
|
||||
if (next === key && live === widths.length + breaks.length) return;
|
||||
key = next;
|
||||
const decos: Decoration[] = widths.map((w) =>
|
||||
// margin-LEFT: the gap is the tab's own advance, so a caret placed after
|
||||
|
||||
Reference in new issue
Block a user