Repository navigation
editor: T-114, follow up Khakha's answers on PR #42 - #45
Merged
Merged
Conversation
Refs: T-114, ED-5, NF-1
…ackslashes A bracket object reads at most 1 MiB each way from where its scan starts and finds no pair past that. From a visual selection longer than one char, a bracket object follows Vim 9.1: the pair is the nth out from before the selection's first char, and i moves out while its inside lies within the selection, so va(a( and vi(i( grow to the next pair out. A quote is escaped only after an odd number of backslashes. Refs: T-114, ED-5, NF-1
Refs: T-114
shubhook
marked this pull request as ready for review
November 28, 2026 12:40
The readers read at least 4 bytes per window and end each window on a char boundary, so a scan could read up to 3 bytes past the window and count a bracket there. find_pair now checks both offsets before it returns a pair. Also rewrap two long doc lines and add tests for the window's edges at chunk boundaries and inside multi-byte chars. Refs: T-114, ED-5, NF-1
Refs: T-114
Only the module comment changes, as granted: > 3. Granted: change the module comment in crates/helm-bench/benches/vim_objects.rs to the wording in PR #45's description. Put it in its own commit, quote this grant, and change nothing else in that file. Refs: T-114, ED-5, NF-1
Council round 2 nits. No behaviour changes. Refs: T-114
This was referenced Nov 28, 2026
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-114, tasks/114-t109-followups.md
PRD: ED-5, NF-1
Khakha's answers and grants
Stage 0, Khakha's answers to PR #42's open questions, as the orchestrator relayed them:
Khakha's answers to this PR's questions, written grants:
Grant 1 needs no change. Under grant 2, no behaviour changes here, and the follow-up task isn't in this PR. Grant 3 is commit 7.
What changed
Nine commits on main at
7638344. Commits 5 and 6 answer council round 1. Commit 7 is grant 3, and commit 8 carries council round 2's nits. Commit 9 records grant 2 in the task file. None of the three changes behaviour. The task file and the work land in one PR, as T-111 did.1.
88f7b52addstasks/114-t109-followups.md. It quotes Khakha's answers to PR #42's open questions as the orchestrator relayed them, and records the Vim 9.1 measurements below.2.
69347efcarries out answers 1 to 3 insrc/motion/vim/object.rs,Editor::vim_select_objectand thevimmodule docs, with the new tests intests/vim_t114.rs.Answer 1, the cap. A bracket object reads at most 1 MiB (
1 << 20bytes) each way from where its scan starts: the cursor, or the first char of a longer visual selection. A pair counts only if both brackets are in[start - 1 MiB, start + 1 MiB). A scan that reaches either end without its bracket finds no pair. Counts and visual growth steps share one window. The backward reader gets a crate-private constructor,Backward::floored, that stops at a floor like a budgeted reader but keeps only its latest window, asBackward::newdoes. The forward reader uses the existingForward::bounded.vim.rslists the cap under "Measured against Vim".Answer 2, repeated visual bracket objects. From a selection longer than one char, a bracket object now follows Vim 9.1's measured rule:
nth out from there.aselects that pair.iselects its inside, and moves out one pair while that inside lies within the selection and is more than one char.So
va(a(andvi(i(grow to the next pair out. A one-char selection still starts a fresh object, and word, quote and paragraph objects are unchanged.Answer 3, escaped quotes.
escaped = c == '\\' && !escaped, so a backslash also escapes a backslash, and a quote is escaped only after an odd number of them.The bracket code is split into
find_pair(the scan) andinside(theirules), whichpairand the newgrow_pairshare. Theirules themselves are unchanged.3.
4e04a27fixes the two comments from round 3 of PR #42's council.EditorId's docs now say the editor owns the only lasting strong reference, and thatCommandRegistry::run_inholds a clone while a command runs. The linewisepcomment now sayssplit_offcopies the 1- or 2-byte line break into a small string while the rest stays in the text's allocation. The third note, the missing CRLF test for normal linewisepbelow a last line with no line break, islinewise_p_below_a_last_line_with_no_crlf_puts_onein commit 2.4.
b34716fcarries out answer 5. Intasks/109-vim-objects.md, "How this compiles without the two pending grants" becomes "How the two grants landed". It describes what merged:CommandArgs::register, the two..CommandArgs::default()literals, and 107 ids, 143 commands, eight modes and 506 bindings (115 + 391).Answer 4 (keep the 1 GiB put limit, refused silently) needs no change.
5.
31c2dcechecks both brackets against the 1 MiB window (council round 1, finding 1). A reader reads at least 4 bytes per window, and it ends each window on a char boundary. So a scan could read up to 3 bytes past the window and count a bracket there. Two cases triggered it: a rope chunk boundary 1 to 3 bytes inside the window, and a multi-byte char across the window's end.find_pairnow returns a pair only ifo >= floor && c < ceiling. A pair further out is also outside the window, so the check never drops a pair inside it. The shared readers, which Up and Down also use, are unchanged. The commit also rewraps two long doc lines (finding 2) and adds six tests tovim_t114.rs. Four of them fail atb34716f:(one byte before the window, with chunk boundaries swept bykleadingxs (fails atk = 980);)at the window's end, swept the same way (fails atk = 368);va(a(growing to an outer pair outside the window (fails atk = 980);éor中across the window's end, with)right after it (fails foré).Two pass at
b34716fand guard against regressions:éor中across the window's start. The old code didn't count a(there, so I couldn't reproduce that half of Gemini's report.6.
89c5bd1records the fix and the six tests in the task file.7.
012a0d4changes the module comment ofcrates/helm-bench/benches/vim_objects.rs, under grant 3. It touches only that file, quotes the grant in its body, and changes one line. The comment now saysdi_paren_no_pair_10mb's "bracket object with no enclosing pair scans 1 MiB of the text before the cursor, the cap T-114 set." Nothing else in the file changed.8.
e34271acarries council round 2's nits.PAIR_SCANis private, since onlyobject.rsuses it. A comment invim_t114.rssays thekranges (940..1030 and 330..420) match where ropey puts chunk boundaries today. If helm-text's chunking changes, those three tests still pass but may stop reaching a boundary. Theéand中tests don't depend on chunks.9.
1d11d5erecords grant 2 in the task file's "Out of scope".No new dependency. No
unsafe. No threading change. No public signature changes. Nothing outsidecrates/helm-editor/src/**, the new test file, the two task files and the granted comment line inbenches/vim_objects.rschanged. No existing test, benchmark code or budget changed. None of answers 1 to 3 changes an existing test's assertion.Protected paths
This PR changes
tasks/114-t109-followups.md(new) andtasks/109-vim-objects.md, both undertasks/**. It also changes one comment line incrates/helm-bench/benches/vim_objects.rs, an existing bench file, under grant 3. The protected-paths check fails until Khakha adds theapproved-protectedlabel.Left as they are
The module docs of
crates/helm-bench/benches/vim_objects.rsused to saydi_paren_no_pair_10mb"scans the text before the cursor to its start". I proposed "a bracket object with no enclosing pair scans 1 MiB of the text before the cursor, the cap T-114 set." Khakha granted it (grant 3), and it is commit 7.tasks/109-vim-objects.mdhas two other sentences written before the grants: the "Choices" bullet ending "That leaves open question 2 open", and the doc comment at the top oftests/vim_harness/mod.rs. Answer 5 covered only the one section, so I left both.Measured against Vim 9.1
vim -u NONE -N -i NONE -n,binary,noeol. Keys were fed withfeedkeys(..., "xt"), and a<Cmd>mapping at the end recorded the mode and both visual ends. I checked that a failing object doesn't flush that mapping. The full tables are in the task file.Answer 2. Each row ends in
d. Vim 9.1 and this PR agree on every row.f(a(b|c)d)eva(a(df|ef(a|d)ef(a(b|c)d)evi(i(df(|)ef(a(|)d)ef(a(b|c)d)eva(i(df(|)ef(a|d)e((((|bc))))vi(i(i(d((|))((((|))))f(a(|b)c(d)e)v4la(df(a|c(d)e)f(a(|e)f(a(b|)c)vli(df(a(|)c)f(|)I also compared two random runs of 3,000 cases each:
v, up to three ofh/l/o, one to three ofi(/a(/2i(/2a(, thend, on one line of(,),a,band spaces.Answer 3. Each row is
di", with the text as a Rust string."\"|a\\\\\"b\""(2 backslashes)"\"|\"b\"""\"|\"""x\\\\\"|a\"b\"""x\\\\\"|\"b\"""x\\\\\"a\"|\"""\"a\\\\\" |x \"c\"""\"a\\\\\"|\"c\"""\"|\"c\"""\"|a\\\\\\\"b\""(3)"\"|\"""\"|\""Differences kept, each listed in
vim.rs:di"fromainx\"a"b"leavesx\""b"in Vim andx\"a""here.va(a(a(inf(a(bc)d)eleaves(bc)selected in Vim. Khakha has asked for a follow-up task to follow Vim's forward search within the 1 MiB cap (grant 2). This PR keeps the difference.Tests
tests/vim_t114.rshas 19 tests. Of the first 13, 10 fail on main at7638344. Of the six from round 1, 4 fail atb34716f. All 19 pass here. The three that pass on main:ptest, a missing test, not a bug;Benchmarks
CI run 46143827954 on
b34716fagainst base7638344, on the same runner.vim_objects/di_paren_no_pair_10mbputs one cursor about 5 MiB into the text. With the cap, its backward scan reads 1 MiB instead of about 5 MiB. Criterion means of the three rounds, from the bench job's artifact (criterion-pr-45-shard-1):7638344b34716fbench-compare, fastest of three medians: 6.062 ms to 752.52 µs, −87.59%. The head is below NF-1's 5 ms keypress budget, which base passed on several of PR #42's runs.
No benchmark is over the 5% gate. bench-compare reported "No benchmark regressed past its budget." The largest increase, as fastest of three medians, is
cursor/down_up_1000_cursors_10mbat +3.38%. The next iscursor/word_right_1000_cursors_10mbat +2.12%. Neither path reaches the changed code. The othervim_objects/benchmarks moved between −0.61% and +0.98%. Since nothing passed the gate, I ran no controlled comparison.Local (macOS aarch64), labelled local:
di_paren_no_pair_10mbhad a criterion mean of 850.68 µs atb34716fand 841.50 µs at89c5bd1.The cap applies per cursor. With N cursors and no pair, one keypress can still read N × 2 MiB (council round 1, finding 4). That is outside this task.
Round 1 fix, CI run 46148812050 on
89c5bd1The table above is from
b34716f. On89c5bd1, against the same base7638344on that run's runner,vim_objects/di_paren_no_pair_10mbgave these criterion means, from the bench job's artifact:763834489c5bd1bench-compare, fastest of three medians: 7.183 ms to 1.128 ms, −84.30%. This runner was slower than
b34716f's: base's means are about 23% higher here. On that slower runner, head is still about 6.7 times faster than base.No benchmark is over the 5% gate. bench-compare reported every row as ok. The largest increase, as fastest of three medians, is
vim_objects/dap_undo_1000_cursors_10mbat +4.07%, which was +0.42% onb34716f. The next isvim_objects/yy_p_undo_1000_cursors_10mbat +3.02%. Neither path reachesfind_pair. Since nothing passed the gate, I ran no controlled comparison.Council review
Each cell is overall score, performance score and verdict.
b34716f89c5bd1Round 1
31c2dce. The 1 MiB window let in a bracket up to 3 bytes outside it. All three reviewers raised it, and two confirmed it with throwaway tests.find_pairnow checks both offsets against the window, and the shared readers are unchanged. Four of the six new tests fail atb34716f: a chunk boundary on either side, visual growth past the window, andéacross the window's end. Gemini's other half, a multi-byte char across the window's start, didn't reproduce. Its test stays as a guard.31c2dce. Two doc lines were longer than the text around them. Rewrapped.31c2dce. No test for a backslash ending the line before a quote. The test passes before and after, as the reviewer expected.Round 2
89c5bd1pending. "Benchmarks" and "Commands run" now give its finished result: criterion means of 7.569 ms for base and 1.136 ms for head, and bench-compare's fastest of three medians, 7.183 ms against 1.128 ms, −84.30%.e34271a. The chunk-boundary tests depend on ropey's chunking. A comment invim_t114.rsnow says that thekranges match where ropey puts chunk boundaries today, and that theéand中tests don't depend on chunks.e34271a.PAIR_SCANwaspub(crate)with no user outsideobject.rs. It is private now.The commits after
89c5bd1change no behaviour.012a0d4is Khakha's grant 3 comment,e34271acarries the round 2 nits, and1d11d5erecords grant 2 in the task file.Commands run
Local, macOS (aarch64), at
e34271a, at the default job count. Commit 9 changes only the task file. Each command's output went to its own log, and each exit code is cargo's own.CI on
89c5bd1(runs 46148812050 and 46148809007): 13 checks passed:test (ubuntu-latest),test (macos-latest),cargo-deny,bench-plan, the eight bench shards and thebenchgate.bench-recordis skipped on PRs by design.protected-pathsfails until Khakha adds theapproved-protectedlabel.Questions for Khakha
None open. Khakha answered the forward-search question (grant 2) and the bench comment (grant 3).
Outside sources
None. Behaviour came from running Vim 9.1 myself, as rule 6 allows. I didn't read Vim's source or
:helppages, or any other editor's code.Agent and model
Claude Code, Claude Opus 5.5 (
claude-opus-5-5), for the whole thread.