Skip empty terminal component maps during span edits

Avoid per-column component lookups and deletions when no component exceptions exist, retaining existing run and mixed-glyph editing.

Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
This commit is contained in:
Brennan Benson
2026-11-13 16:54:46 -08:00
co-authored by Jinjing
parent b5c3ab69f5
commit ccdd3ba2a0
2 changed files with 9 additions and 5 deletions
@@ -96,8 +96,10 @@ export class HeadlessContentOrigins {
this.pending = undefined
const state = this.lines.get(pending.line)!
const components = state.components
for (let index = pending.start; index < pending.end; index++) {
components.delete(index)
if (components.size) {
for (let index = pending.start; index < pending.end; index++) {
components.delete(index)
}
}
this.assign(pending.line, {
runs: writeTerminalOrigins(
@@ -13,15 +13,17 @@ export function replaceOriginCells(
from = 0
): OriginLineState {
const copied: [number, TerminalOriginRuns][] = []
for (let index = from; source && index < from + end - start; index++) {
for (let index = from; source?.components.size && index < from + end - start; index++) {
const runs = source.components.get(index)
if (runs) {
copied.push([index - from + start, runs])
}
}
const components = target.components
for (let index = start; index < end; index++) {
components.delete(index)
if (components.size) {
for (let index = start; index < end; index++) {
components.delete(index)
}
}
for (const [index, runs] of copied) {
components.set(index, runs)