MCPcopy
hub / github.com/marktext/marktext / syncLineNumbersSpans

Function syncLineNumbersSpans

packages/muya/src/utils/codeBlockLineNumbers.ts:30–40  ·  view source on GitHub ↗
(wrapper: HTMLElement, count: number)

Source from the content-addressed store, hash-verified

28// O(delta), not O(count) — typing within a line is free once the count
29// matches.
30export function syncLineNumbersSpans(wrapper: HTMLElement, count: number): void {
31 let current = wrapper.childElementCount;
32 while (current < count) {
33 wrapper.appendChild(wrapper.ownerDocument.createElement('span'));
34 current++;
35 }
36 while (current > count) {
37 wrapper.lastElementChild!.remove();
38 current--;
39 }
40}

Callers 2

_updateLineNumbersMethod · 0.90

Calls 2

appendChildMethod · 0.80
removeMethod · 0.45

Tested by

no test coverage detected