Repository navigation
editor: T-112, group VS Code typing into undo steps - #49
Merged
Merged
Conversation
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
Refs: T-112, ED-2, ED-4
shubhook
marked this pull request as ready for review
November 29, 2026 10:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task: T-112, tasks/112-vscode-undo-groups.md
PRD: ED-2, ED-4
What changed
Two commits, on main at
23b1862.1.
44fbcdcis 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 intyping_groups.rs, 10 invscode_undo.rs, 4 intyping_group_properties.rs). Nothing else in those three files changed.Editorgets four private fields: the grouping, the time fromset_time, the open typing group's last kind and time (Nonewhile no group or an explicit one is open), and the move flag. The hand-writtenClonecopies all four.insertandnewlineare typing.delete_backward,delete_forwardanddelete_toget their kind from the spec's lists.delete_towith any motion not in the backward list counts as forward.applyis split.apply_in_groupis the old body (amend, or apply a new transaction whenamendrefuses).apply_stephandles typing and deleting edits. UnderTypingwith no explicit group open, it decides whether the edit joins the open group and then records the edit's kind and time.applyis the path for other edits (Vim's commands and puts). UnderTypingit ends an open typing group first, so the edit is its own step and leaves no group open.set_selectionscompares 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'safter. It uses the record, so nothing is copied.byte_to_linelookups per joined delete range. It runs only when a typing group is open, soExplicitgrouping skips it.undo,redo,begin_undo_group,end_undo_groupand a grouping change clear the typing state.Keymapgets a privategroupingfield,ExplicitfromKeymap::new.vscode::keymap()callswith_undo_grouping(Typing).dispatchanddispatch_incallset_undo_groupingbeforerunorrun_in, sorun_in's record check sees a group the switch ended.2.
d248203addsbenches/typing.rsand its[[bench]]entry, with the threetyping/benchmarks the spec lists.LINES,floor_boundaryandbuild_textare copied unchanged frombenches/cursor.rs. The single cursor sits at the middle of the 1,000fn main() {lines, asbenches/vim.rsplaces itsmiddle. 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'sapproved-protectedlabel. Khakha checks the diff of those three files before adding it.git diff main -- crates/helm-editor/testsshows 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:Local criterion means from that
cargo benchrun on the M2, atd248203. They are local numbers, for information only, and don't stand in for the CI numbers below.typing/type_100_chars_undo_10mbtyping/type_10_chars_undo_1000_cursors_10mbtyping/vscode_session_undo_10mbCI benchmarks
From CI run 46252776649, base
23b1862against headd248203, three alternating rounds on one runner.typing/, head only. Criterion means from artifactcriterion-pr-49-shard-0(estimates.json,mean.point_estimate), one per round. Thetyping/benchmarks are new in this PR, so there is no base to compare with. The bench job's summary reports them asnew, with fastest-of-three medians of 114.05 µs, 11.202 ms and 23.05 µs.typing/type_100_chars_undo_10mbtyping/type_10_chars_undo_1000_cursors_10mbtyping/vscode_session_undo_10mbExisting 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 artifactscriterion-pr-49-shard-0tocriterion-pr-49-shard-7. Every benchmark is within its 5% budget, and the job reports "No benchmark regressed past its budget." The largest slowdown isvim/counted_j_k_1000_cursors_10mbat +3.34%.editor/type_undo_1000_cursors_10mbcursor/down_up_1000_cursors_10mbcursor/word_right_1000_cursors_10mbamend/type_100_chars_undo_10mbvim/counted_dollar_1000_cursors_10mbvim/counted_j_k_1000_cursors_10mbvim/d3w_undo_1000_cursors_10mbvim/dd_undo_1000_cursors_10mbvim/gg_G_1000_cursors_10mbvim/insert_100_chars_undo_10mbvim/visual_w_d_undo_1000_cursors_10mbvim/w_b_1000_cursors_10mbvim_objects/ci_quote_undo_1000_cursors_10mbvim_objects/clipboard_paste_1mbvim_objects/dap_undo_1000_cursors_10mbvim_objects/di_brace_undo_1000_cursors_10mbvim_objects/di_paren_no_pair_10mbvim_objects/diw_undo_1000_cursors_10mbvim_objects/insert_count_100_10mbvim_objects/repeat_ciw_1000_cursors_10mbvim_objects/yy_p_undo_1000_cursors_10mbkeymap/resolve_10k_keys_300_bindingsThe
encoding/,snapshots/,text/andtransactions/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
d248203while the PR was open, but only delegate 2 finished before the merge. Delegates 1 and 3 ran on 29 November 2026 on the merge commitbc495ec, whose tree is identical tod248203. Nobody pushed.bc495ecd248203bc495ecNo delegate found a bug. Delegate 1 ran
cargo test -p helm-editor --lockedatbc495ec, and delegate 3 ran thehelm-editortests andcargo clippy -D warningsthere. All passed. Both confirmed that the only change to the three test files is the 39 deleted#[ignore]lines.Findings:
editor.rs:913:note_other_movesruns beforereplace_eachanddelete_eachreturn 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.editor.rs:71: the_ => Forwardwildcard inKind::of_deletewould count a futureMotionvariant as deleting forward. An exhaustive match would make it fail to compile instead.begin_undo_group,end_undo_group,undoandredoleavemovedset. Users can't see it: no edit joins whiletypingisNone, and the next edit clearsmoved.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.editor.rs:910: each typing edit does aHashMaplookup and an O(k) comparison of the selections. Within the spec's one-pass rule. Not measured.Explicitgrouping, an edit makes a few O(1) checks beyond the spec's "one grouping check".vscode.rs:524writescrate::UndoGrouping::Typinginline instead of importing it.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
44fbcdcandd248203. 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.