Repository navigation
Closed
Labels
app/idPackage/app: id (pkgs/ or apps/ in this repo)Package/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)Something isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)Ordinary priority (the default)source/creatorFiled by the new-issue-creator jobFiled by the new-issue-creator jobstatus:in-reviewtask/triageQueue packet kind: verify, reproduce, and route this itemQueue packet kind: verify, reproduce, and route this item
Description
id(web): Tab/Shift-Tab with a selection spanning multiple blocks corrupts a paragraph and skips later code blocks
Summary
indentCommand / dedentCommand in pkgs/id/web/src/indent.ts assume the
selection lives inside a single code_block. When a selection starts in a
code block and extends across other blocks (select-all is the easy trigger),
the commands treat the whole span as one block's text:
- code blocks after the first are never indented/dedented, and
- the line-start math (computed over
doc.textBetween(blockStart, blockEnd),
whose block separators do not exist as document positions) lands inside a
neighbouring paragraph and inserts spaces into it — corrupting non-code
content with a formatting keystroke.
Evidence (verified this run, main 452d69e)
Targeted vitest probes against the real commands + richSchema (probe files
preserved in the fleet's run records; run with bunx vitest run in
pkgs/id/web):
- Doc = code_block(
x\ny) + paragraph(mid) + code_block(p\nq), select
all, Tab →- code_block 1 becomes
x\n y(correct), - paragraph becomes
mid— two spaces appended to the paragraph text, - code_block 2 stays
p\nq— never indented.
- code_block 1 becomes
- Doc = code_block(
one) + paragraph(keep me) + code_block(two), select
all, Tab → only the first block is indented;twois untouched. - Controls behave: a selection entirely inside one code block works
(existingindent.test.tssuite), and a selection entirely inside a
paragraph returnsfalse(theinCodegate at indent.ts:42-46 only
inspects$from's parent).
Root cause
indent.ts:63-65(indent) andindent.ts:100-102(dedent):blockStart
comes from$from.start($from.depth)andblockEndfrom
$to.end($to.depth)— two different nodes when the selection spans blocks —
andtextBetween(blockStart, blockEnd)is then scanned for\nas if it
were a single code block's text. Positions derived from that joined string
do not correspond to document positions once block boundaries (and
textBetween's separators) intervene.- The
inCodecheck (indent.ts:42-49, 93-97) only examines the selection's
head parent, so a spanning selection is accepted and processed with the
single-block math. This is the multi-block sibling of id(web): Tab/Shift-Tab on a selection indents/dedents the wrong lines — unselected lines changed, selection's first line skipped #714 (which fixed
wrong-line selection within one block; its tests still only build
single-code-block documents).
Why it matters
Tab is a formatting key users hit with large selections reflexively
(select-all + Tab to reindent a file is a standard gesture). Today that
gesture silently edits prose paragraphs and leaves later code blocks
unindented — a data-corruption papercut in the editor's most basic
indentation path.
Acceptance criteria
- Tab with a selection spanning multiple blocks indents the selected
lines of every code_block the selection overlaps, and modifies no
non-code content (paragraph text byte-identical). - Shift-Tab under the same conditions dedents every overlapped
code_block's selected lines, with the same no-prose-edits guarantee. - Single-block behaviour is unchanged: the existing
indent.test.ts
suite (including the id(web): Tab/Shift-Tab on a selection indents/dedents the wrong lines — unselected lines changed, selection's first line skipped #714 cases) passes unmodified. - New tests cover multi-block selections (code+paragraph, and
code+paragraph+code) for both commands, including select-all.
Metadata
Metadata
Assignees
Labels
app/idPackage/app: id (pkgs/ or apps/ in this repo)Package/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)Something isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)Ordinary priority (the default)source/creatorFiled by the new-issue-creator jobFiled by the new-issue-creator jobstatus:in-reviewtask/triageQueue packet kind: verify, reproduce, and route this itemQueue packet kind: verify, reproduce, and route this item
Activity
developing-today commentedon Oct 27, 2026
CODE-490
dezren39 commentedon Oct 27, 2026
🤖 Agent note · filed
57 remaining items
dezren39 commentedon Oct 31, 2026
🤖 Agent note · parked
fix(id/web): per-block indent/dedent for multi-block selections (#1399)…
dezren39 commentedon Oct 31, 2026
🤖 Agent note · done
tsc --noEmitexit 0, indent tests 31/31, full web suite 485 passed / 1 failed — the one failure is search-panel.test.ts's aria-label expectation ("Replace all" vs "Replace all matches"), in files this PR does not touch and byte-identical to main: pre-existing. This issue auto-closed by the merge.