Skip to content

editor: T-112, group VS Code typing into undo steps - #49

Merged
shubhook merged 2 commits into
mainfrom
t3/t112-vscode-undo-groups
Nov 29, 2026
Merged

shubhook merged 2 commits into
mainfrom
t3/t112-vscode-undo-groups

Conversation

@shubhook

@shubhook shubhook commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Task: T-112, tasks/112-vscode-undo-groups.md

PRD: ED-2, ED-4

What changed

Two commits, on main at 23b1862.

1. 44fbcdc is the implementation. It fills every T-112 stub, deletes the three stub #[expect]s, and deletes the 39 #[ignore = "T-112: not implemented yet"] lines (25 in typing_groups.rs, 10 in vscode_undo.rs, 4 in typing_group_properties.rs). Nothing else in those three files changed.

  • Editor gets four private fields: the grouping, the time from set_time, the open typing group's last kind and time (None while no group or an explicit one is open), and the move flag. The hand-written Clone copies all four.
  • insert and newline are typing. delete_backward, delete_forward and delete_to get their kind from the spec's lists. delete_to with any motion not in the backward list counts as forward.
  • apply is split. apply_in_group is the old body (amend, or apply a new transaction when amend refuses). apply_step handles typing and deleting edits. Under Typing with no explicit group open, it decides whether the edit joins the open group and then records the edit's kind and time. apply is the path for other edits (Vim's commands and puts). Under Typing it ends an open typing group first, so the edit is its own step and leaves no group open.
  • A move sets the flag when one of the nine methods changes the selections. set_selections compares the old and new selections. The other eight already compute whether they changed anything. For changes made outside those nine (Vim's motions), each typing or deleting edit compares the selections, before clamping, with the open group's undo record's after. It uses the record, so nothing is copied.
  • The line-break rule makes two byte_to_line lookups per joined delete range. It runs only when a typing group is open, so Explicit grouping skips it.
  • undo, redo, begin_undo_group, end_undo_group and a grouping change clear the typing state.
  • Keymap gets a private grouping field, Explicit from Keymap::new. vscode::keymap() calls with_undo_grouping(Typing). dispatch and dispatch_in call set_undo_grouping before run or run_in, so run_in's record check sees a group the switch ended.
  • The editor never reads a clock.

2. d248203 adds benches/typing.rs and its [[bench]] entry, with the three typing/ benchmarks the spec lists. LINES, floor_boundary and build_text are copied unchanged from benches/cursor.rs. The single cursor sits at the middle of the 1,000 fn main() { lines, as benches/vim.rs places its middle. Each benchmark keeps its own clock and moves it 10 ms per key, and the file asserts after each benchmark that the selections are back where they started, and at the end that the text is too.

No new dependency. No unsafe. No threading change. No acceptance test, existing benchmark, budget, doc or CI file changed.

Protected paths

Deleting the ignore lines edits three existing files under crates/helm-editor/tests/, so the protected-paths check waits on Khakha's approved-protected label. Khakha checks the diff of those three files before adding it. git diff main -- crates/helm-editor/tests shows 39 deleted lines and nothing else.

Things that may not match the spec

None found. Every T-101 to T-114 test passes unchanged.

Commands run

Local, macOS aarch64 (M2), at d248203:

$ cargo build --workspace                                         # exit 0
$ cargo test --workspace --locked                                 # exit 0, 623 passed, 0 failed, 0 ignored
$ cargo fmt --all --check                                         # exit 0
$ cargo clippy --workspace --all-targets --locked -- -D warnings  # exit 0
$ cargo deny --all-features --locked check                        # exit 0, advisories ok, bans ok, licenses ok, sources ok
$ cargo bench -p helm-bench --locked                              # exit 0, 32 benchmarks ran

Local criterion means from that cargo bench run on the M2, at d248203. They are local numbers, for information only, and don't stand in for the CI numbers below.

Benchmark Local criterion mean
typing/type_100_chars_undo_10mb 120.84 µs
typing/type_10_chars_undo_1000_cursors_10mb 9.4654 ms
typing/vscode_session_undo_10mb 22.890 µs

CI benchmarks

From CI run 46252776649, base 23b1862 against head d248203, three alternating rounds on one runner.

typing/, head only. Criterion means from artifact criterion-pr-49-shard-0 (estimates.json, mean.point_estimate), one per round. The typing/ benchmarks are new in this PR, so there is no base to compare with. The bench job's summary reports them as new, with fastest-of-three medians of 114.05 µs, 11.202 ms and 23.05 µs.

Benchmark Round 1 mean Round 2 mean Round 3 mean
typing/type_100_chars_undo_10mb 115.44 µs 114.74 µs 115.89 µs
typing/type_10_chars_undo_1000_cursors_10mb 11.260 ms 11.251 ms 11.341 ms
typing/vscode_session_undo_10mb 23.98 µs 23.11 µs 23.53 µs

Existing benchmarks, base against head. These are bench-compare's fastest of three medians, from the bench job's step summary ("Compare against budgets"), built from artifacts criterion-pr-49-shard-0 to criterion-pr-49-shard-7. Every benchmark is within its 5% budget, and the job reports "No benchmark regressed past its budget." The largest slowdown is vim/counted_j_k_1000_cursors_10mb at +3.34%.

Benchmark Base Head Change Result
editor/type_undo_1000_cursors_10mb 881.18 µs 873.93 µs -0.82% ok
cursor/down_up_1000_cursors_10mb 268.37 µs 271.71 µs +1.25% ok
cursor/word_right_1000_cursors_10mb 197.58 µs 204.03 µs +3.26% ok
amend/type_100_chars_undo_10mb 87.18 µs 86.72 µs -0.52% ok
vim/counted_dollar_1000_cursors_10mb 720.33 µs 731.78 µs +1.59% ok
vim/counted_j_k_1000_cursors_10mb 1.540 ms 1.591 ms +3.34% ok
vim/d3w_undo_1000_cursors_10mb 2.304 ms 2.289 ms -0.65% ok
vim/dd_undo_1000_cursors_10mb 3.532 ms 3.608 ms +2.15% ok
vim/gg_G_1000_cursors_10mb 90.39 µs 91.11 µs +0.80% ok
vim/insert_100_chars_undo_10mb 131.39 µs 132.46 µs +0.81% ok
vim/visual_w_d_undo_1000_cursors_10mb 2.587 ms 2.609 ms +0.85% ok
vim/w_b_1000_cursors_10mb 353.82 µs 352.39 µs -0.40% ok
vim_objects/ci_quote_undo_1000_cursors_10mb 2.899 ms 2.823 ms -2.63% ok
vim_objects/clipboard_paste_1mb 270.56 µs 268.87 µs -0.63% ok
vim_objects/dap_undo_1000_cursors_10mb 3.812 ms 3.670 ms -3.73% ok
vim_objects/di_brace_undo_1000_cursors_10mb 2.867 ms 2.816 ms -1.76% ok
vim_objects/di_paren_no_pair_10mb 695.06 µs 711.72 µs +2.40% ok
vim_objects/diw_undo_1000_cursors_10mb 1.295 ms 1.270 ms -1.95% ok
vim_objects/insert_count_100_10mb 90.21 µs 91.96 µs +1.94% ok
vim_objects/repeat_ciw_1000_cursors_10mb 4.973 ms 4.894 ms -1.59% ok
vim_objects/yy_p_undo_1000_cursors_10mb 3.531 ms 3.408 ms -3.50% ok
keymap/resolve_10k_keys_300_bindings 741.24 µs 743.97 µs +0.37% ok

The encoding/, snapshots/, text/ and transactions/ benchmarks are also within budget, at -0.43% to +0.21%.

Grants

None. The brief allows deleting the T-112 ignore lines, and the task file allows the new benchmark file and its [[bench]] entry.

Outside sources

None. I followed the task file and the repo's own code. I read no VS Code source, no other editor's code and no Vim material.

Council review

The council ran after the merge. Round 1 started on head d248203 while the PR was open, but only delegate 2 finished before the merge. Delegates 1 and 3 ran on 29 November 2026 on the merge commit bc495ec, whose tree is identical to d248203. Nobody pushed.

Delegate Agent and model Commit Overall Performance Verdict
1 Claude Code, Claude Opus 5.5 bc495ec 9/10 9/10 SATISFIED
2 Codex, GPT-6.1 Sol d248203 9/10 9/10 SATISFIED
3 Cursor, Auto (the reviewer reported Composer) bc495ec 9/10 9/10 SATISFIED

No delegate found a bug. Delegate 1 ran cargo test -p helm-editor --locked at bc495ec, and delegate 3 ran the helm-editor tests and cargo clippy -D warnings there. All passed. Both confirmed that the only change to the three test files is the 39 deleted #[ignore] lines.

Findings:

# From Finding Kind
1 1 editor.rs:913: note_other_moves runs before replace_each and delete_each return early for an edit that does nothing, so a no-op delete can record a move. Under the spec, a Vim motion away, a Backspace that deletes nothing, then a motion back keeps the step. Here it ends the step. No keymap reaches it today. Minor spec gap
2 1 editor.rs:71: the _ => Forward wildcard in Kind::of_delete would count a future Motion variant as deleting forward. An exhaustive match would make it fail to compile instead. Nit
3 3 begin_undo_group, end_undo_group, undo and redo leave moved set. Users can't see it: no edit joins while typing is None, and the next edit clears moved. Nit
4 1 editor.rs:880: the line-break lookups also run when the pause, a move or a kind change already starts a step. Two O(log n) lookups per range, within the spec's cost rules. Performance nit
5 1 editor.rs:910: each typing edit does a HashMap lookup and an O(k) comparison of the selections. Within the spec's one-pass rule. Not measured. Performance nit
6 3 Under Explicit grouping, an edit makes a few O(1) checks beyond the spec's "one grouping check". Performance nit
7 1 vscode.rs:524 writes crate::UndoGrouping::Typing inline instead of importing it. Style

T-117: Khakha has not yet chosen which findings go to T-117. This section will name them once Khakha does.

Agent and model

Claude Code with Claude Opus 5.5 wrote commits 44fbcdc and d248203. Claude Code hit its weekly usage limit at about 16:02 IST on 29 November 2026, after those commits were pushed. The work then continued in Cursor with Claude Opus 5.5, which wrote this description's CI benchmark section and would write any later commits.

Fills the T-112 stubs. Under UndoGrouping::Typing the editor opens and
closes typing groups itself by the "Typing groups" rules: kind, moves,
newline, deleted line breaks and TYPING_PAUSE. vscode::keymap() carries
Typing, and dispatch and dispatch_in set the editor's grouping before
running a command. Deletes the 39 T-112 ignore lines and nothing else
in the three test files.

Refs: T-112, ED-2, ED-4
@shubhook
shubhook marked this pull request as ready for review November 29, 2026 10:55
@shubhook shubhook added the approved-protected Khakha approves a change to a protected path. Agents never add or remove it. label Nov 29, 2026
@shubhook
shubhook merged commit bc495ec into main Nov 29, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved-protected Khakha approves a change to a protected path. Agents never add or remove it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant