MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / deleteRange

Method deleteRange

packages/app-core/src/lib/cm-table.ts:1005–1017  ·  view source on GitHub ↗

Delete `[from, to)` from the focused cell's source in place (no dispatch — * committed on blur, like typing). Re-renders the NORMAL block cursor.

(cell: HTMLElement, from: number, to: number)

Source from the content-addressed store, hash-verified

1003 /** Delete `[from, to)` from the focused cell's source in place (no dispatch —
1004 * committed on blur, like typing). Re-renders the NORMAL block cursor. */
1005 private deleteRange(cell: HTMLElement, from: number, to: number): void {
1006 const text = cell.dataset.raw ?? ''
1007 const a = Math.max(0, Math.min(from, text.length))
1008 const b = Math.max(a, Math.min(to, text.length))
1009 if (b === a) return
1010 const next = text.slice(0, a) + text.slice(b)
1011 cell.dataset.raw = next
1012 this.dirty = true
1013 this.cursorOffset = Math.max(0, Math.min(a, next.length - 1))
1014 cell.textContent = next
1015 cell.dataset.rendered = 'false'
1016 this.renderCellCursor(cell)
1017 }
1018
1019 /** Apply a pending operator (`d`/`c`) over the motion in `key`: dd/cc clear
1020 * the cell; dw/cw, d$/c$, d0/c0, dl, db act over that range. `c` then edits. */

Callers 3

onCellKeydownMethod · 0.95
applyOperatorMethod · 0.95
handleVisualKeyMethod · 0.95

Calls 1

renderCellCursorMethod · 0.95

Tested by

no test coverage detected