From 88f7b520826663af7b663e818a44a285b6a613f8 Mon Sep 17 00:00:00 2001 From: shubhook Date: Sat, 28 Nov 2026 17:45:16 +0530 Subject: [PATCH 1/9] tasks: add T-114, the follow-ups to Khakha's answers on PR #42 Refs: T-114, ED-5, NF-1 --- tasks/114-t109-followups.md | 107 ++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 tasks/114-t109-followups.md diff --git a/tasks/114-t109-followups.md b/tasks/114-t109-followups.md new file mode 100644 index 0000000..fa256c2 --- /dev/null +++ b/tasks/114-t109-followups.md @@ -0,0 +1,107 @@ +# T-114: Follow up Khakha's answers to PR #42's open questions + +After: T-109. This task waits until that one is merged. It is, as PR #42 (`7638344`). + +## Goal + +PR #42 (T-109) merged with five open questions for Khakha and three nonblocking notes from its third council round. This task carries out Khakha's answers: it caps the bracket scan at 1 MiB, grows repeated visual bracket objects to the next pair out, counts backslashes before a quote as Vim does, keeps the 1 GiB put limit, and brings a stale section of `tasks/109-vim-objects.md` up to date. It also fixes two comments and adds the missing CRLF test from round 3. Like T-111, the task file and the work land in one PR. + +PRD: ED-5, NF-1 + +## Crates and public interface + +Crates: `helm-editor`, in `src/**` and new files in `tests/`. Also `tasks/114-t109-followups.md`, and `tasks/109-vim-objects.md` for answer 5 only. Nothing in `helm-text` or `helm-bench`. + +No public type, trait or function changes. The work changes crate-private code in `src/motion/vim/object.rs`, `src/editor/vim.rs` (`Editor::vim_select_object`) and `src/motion.rs` (a `Backward::floored` constructor), the `vim` module docs in `src/vim.rs`, and two comments in `src/editor.rs` and `src/editor/vim.rs`. + +## Khakha's answers + +Quoted as the orchestrator relayed them: + +> Answers to PR #42's open questions, from Khakha: +> 1. Question 6 (no-pair bracket scan): cap the scan at 1 MiB in each direction from the cursor, and treat a capped scan as no pair. List it in vim.rs's 'Measured against Vim' as a difference. +> 2. Repeated visual bracket objects (va(a(, vi(i(): grow to the next pair out, as Vim does. +> 3. Escaped quotes: a quote is escaped only when an odd number of backslashes come right before it, as Vim does. +> 4. The 1 GiB put limit: keep it, refused silently, for now. Feedback for a refused put is a later helm-ui task. +> 5. Update the stale 'How this compiles without the two pending grants' section of tasks/109-vim-objects.md to describe what merged. +> +> If any of 1 to 3 would change an assertion in an existing test, stop and tell me which one. + +None of 1 to 3 changes an existing test's assertion. Every existing test passes unchanged. + +## The work + +1. **The bracket scan's cap.** A bracket object reads at most 1 MiB (`1 << 20` bytes) 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 lie from 1 MiB before that point up to, not including, 1 MiB after it. A scan that reaches either end without its bracket finds no pair. A count and a visual growth step share the same window. `vim.rs` lists the cap under "Measured against Vim". +2. **Visual bracket objects from a longer selection.** Measured in Vim 9.1 (`vim -u NONE -N -i NONE -n`, `binary`, `noeol`), Vim's rule for a selection longer than one char is: + - The scan starts before the selection's first char, so a bracket there isn't the pair's. The pair is the `n`th out from there. + - `a` selects that pair. + - `i` selects its inside. While that inside lies within the selection and is more than one char, it moves out one pair. + - The new selection runs forward, from the pair's first char to its last, whichever way the old one ran. + + So `va(a(` and `vi(i(` grow to the next pair out. Helm now does this for bracket objects. A one-char selection still starts a fresh object, and word, quote and paragraph objects don't change. +3. **Escaped quotes.** A backslash escapes the char after it, including another backslash, so a quote is escaped only after an odd number of backslashes. +4. **The 1 GiB put limit.** Unchanged, as answered. +5. **`tasks/109-vim-objects.md`.** The section "How this compiles without the two pending grants" becomes "How the two grants landed" and describes what merged. It is its own commit. +6. **Round 3's notes.** + - `EditorId`'s docs said the editor owns the only strong reference. They now say it owns the only lasting one, and that `CommandRegistry::run_in` holds a clone while a command runs. + - The comment on normal linewise `p` below a last line with no line break said the bytes move in place. It now says `split_off` copies the line break, 1 or 2 bytes, into a small string, and the rest stays in the text's own allocation. + - The CRLF test for that `p` is added. + +### Measured against Vim 9.1 + +Text is shown as a Rust string, `|` before the char the cursor is on. The main column was run on `7638344`. + +Repeated and longer-selection bracket objects, each ending in `d`: + +| Text | Keys | Vim 9.1 and Helm after T-114 | Helm on main | +| --- | --- | --- | --- | +| `"f(a(b\|c)d)e"` | `va(a(d` | `"f\|e"` | `"f(a\|d)e"` | +| `"f(a(b\|c)d)e"` | `vi(i(d` | `"f(\|)e"` | `"f(a(\|)d)e"` | +| `"f(a(b\|c)d)e"` | `vi(a(d` | `"f(a\|d)e"` | `"f(a\|d)e"` | +| `"f(a(b\|c)d)e"` | `va(i(d` | `"f(\|)e"` | `"f(a\|d)e"` | +| `"((((\|bc))))"` | `vi(2i(d` | `"(((\|)))"` | `"(((\|)))"` | +| `"((((\|bc))))"` | `vi(i(i(d` | `"((\|))"` | `"((((\|))))"` | +| `"f(a(\|b)c(d)e)"` | `v4la(d` | `"f(a\|c(d)e)"` | `"f(a(\|e)"` | +| `"f(a(\|b)c(d)e)"` | `v4li(d` | `"f(a(\|)c(d)e)"` | `"f(a(\|)e)"` | +| `"f(a(b\|)c)"` | `vli(d` | `"f(a(\|)c)"` | `"f(\|)"` | + +Beyond the table rows, two runs of 3,000 random cases each compared Helm with Vim: `v`, up to three of `h`, `l` and `o`, one to three of `i(`, `a(`, `2i(` and `2a(`, then `d`, on one line of `(`, `)`, `a`, `b` and spaces. Where ten pairs enclose the cursor, none of the 3,000 differ. On random lines, 286 differ, and each has a step where no pair encloses the selection's start. Vim then looks forward for a pair (below), and Helm keeps the selection. A Python model of Helm's rule gives Helm's result in all 6,000 cases. The scripts stayed in the scratch directory and are not in the PR. + +Escaped quotes: + +| Text | Keys | Vim 9.1 and Helm after T-114 | Helm on main | +| --- | --- | --- | --- | +| `"\"\|a\\\\\"b\""` | `di"` | `"\"\|\"b\""` | `"\"\|\""` | +| `"\"a\\\\\|\"b\""` | `di"` | `"\"\|\"b\""` | `"\"\|\""` | +| `"x\\\\\"\|a\"b\""` | `di"` | `"x\\\\\"\|\"b\""` | `"x\\\\\"a\"\|\""` | +| `"\"a\\\\\" \|x \"c\""` | `di"` | `"\"a\\\\\"\|\"c\""` | `"\"\|\"c\""` | +| `"\"\|a\\\\\\\"b\""` | `di"` | `"\"\|\""` | `"\"\|\""` | + +### Differences found, kept + +Each is listed under "Measured against Vim" in `vim.rs`: + +- The 1 MiB cap (answer 1). +- With no pair around the cursor, Vim 9.1 looks for the next pair after it, even on a later line: `di(` from `b` in `"a b (c) d"` leaves `"a b () d"`. Helm finds nothing, in normal and visual modes, before and after this task. In a visual mode with no pair out from the selection's start, Vim can then select a pair inside the selection: `va(a(a(` from `c` in `"f(a(bc)d)e"` leaves `(bc)` selected. Helm keeps `(a(bc)d)` selected, by the rule that an object that finds nothing leaves the selection alone. +- With no unescaped quote before the cursor, Vim takes the line's first quote as the opening one even if it is escaped: `di"` from `a` in `"x\\\"a\"b\""` leaves `"x\\\"\"b\""`. Helm leaves `"x\\\"a\"\""`. +- A grown inner block of lines in a visual mode stops on the closing line's last char, where Vim takes its line break too, as for every visual end since T-108. + +## Acceptance tests + +| File | What it proves | +| --- | --- | +| `crates/helm-editor/tests/vim_t114.rs` (13, new) | Answers 2 and 3 with the Vim rows above, the cap with a pair just inside and just outside 1 MiB each way, a count and a visual growth stopped by the cap, the forward direction of a grown selection, the kept differences, and the CRLF row for `p`. Ten of the 13 fail on main at `7638344`. The three that pass there are the CRLF `p` test, the capped visual growth (main keeps that selection too) and the escaped quote that never opens a pair (main counts a single backslash too). | + +Every existing test passes unchanged. + +## Performance budget + +The cap bounds `vim_objects/di_paren_no_pair_10mb`. Its single cursor sits about 5 MiB into the text, so the backward scan reads 1 MiB, not about 5 MiB, and the benchmark should get faster. The PR reports its CI criterion means from the bench job's artifact against base. Every other benchmark stays within the default 5% gate in `budgets.toml`. No budget changes. + +The doc comment of `crates/helm-bench/benches/vim_objects.rs` still says this benchmark scans to the text's start. That file is protected, so this task leaves it and the PR description proposes the new wording. + +## Out of scope + +- Vim's forward search for a pair when none encloses the cursor. That is a question for Khakha. +- Feedback for a refused put, a later `helm-ui` task (answer 4). +- Visual ends on a line break, kept since T-108. From 69347ef87c9d50e072ebdd5e709d80bee0172fe2 Mon Sep 17 00:00:00 2001 From: shubhook Date: Sat, 28 Nov 2026 17:45:16 +0530 Subject: [PATCH 2/9] editor: cap the bracket scan, grow visual bracket objects and count backslashes 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 --- crates/helm-editor/src/editor/vim.rs | 3 + crates/helm-editor/src/motion.rs | 9 + crates/helm-editor/src/motion/vim/object.rs | 107 +++++++++-- crates/helm-editor/src/vim.rs | 41 ++++- crates/helm-editor/tests/vim_t114.rs | 192 ++++++++++++++++++++ 5 files changed, 331 insertions(+), 21 deletions(-) create mode 100644 crates/helm-editor/tests/vim_t114.rs diff --git a/crates/helm-editor/src/editor/vim.rs b/crates/helm-editor/src/editor/vim.rs index 08bb386..de038bd 100644 --- a/crates/helm-editor/src/editor/vim.rs +++ b/crates/helm-editor/src/editor/vim.rs @@ -1004,6 +1004,9 @@ impl Editor { o::span(buffer, &mut reads, cursor, object, count) .filter(|span| !matches!(span, Span::Chars(r) if r.is_empty())) .map(|span| o::visual_ends(buffer, &mut reads, &span)) + } else if matches!(object.kind, o::Kind::Pair { .. }) { + let ends = (anchor.min(cursor), anchor.max(cursor)); + o::grow_pair(buffer, &mut reads, ends, object, count) } else if matches!(object.kind, o::Kind::Word { .. }) && cursor > anchor { let from = o::after(buffer, &mut reads, cursor); o::word_from(buffer, &mut reads, from, object, count).map(|span| { diff --git a/crates/helm-editor/src/motion.rs b/crates/helm-editor/src/motion.rs index d4646f8..6edb824 100644 --- a/crates/helm-editor/src/motion.rs +++ b/crates/helm-editor/src/motion.rs @@ -483,6 +483,15 @@ impl<'a> Backward<'a> { Self::bounded(buffer, slot, offset, WINDOW, usize::MAX) } + /// A reader that reads nothing before `floor` (T-114): it stops there as + /// at the limit of a budget, but keeps only its latest window, as one + /// made with [`Backward::new`] does. + fn floored(buffer: &'a Buffer, slot: &'a mut Window, offset: usize, floor: usize) -> Self { + let mut reader = Self::new(buffer, slot, offset); + reader.limit = floor.min(offset); + reader + } + fn bounded( buffer: &'a Buffer, slot: &'a mut Window, diff --git a/crates/helm-editor/src/motion/vim/object.rs b/crates/helm-editor/src/motion/vim/object.rs index 3acaf87..2f7317e 100644 --- a/crates/helm-editor/src/motion/vim/object.rs +++ b/crates/helm-editor/src/motion/vim/object.rs @@ -4,8 +4,8 @@ //! //! Word objects read a window at a time from the cursor and stop at the //! line's ends. Quote objects read the cursor's line from its start. -//! Bracket objects read outward from the cursor and use the line index -//! only for the block rule at the end. Paragraph objects use a fixed +//! Bracket objects read outward from the cursor, at most 1 MiB each way, +//! and use the line index only for the block rule at the end. Paragraph objects use a fixed //! number of line-index lookups per line they cross. use std::cell::Cell; @@ -17,7 +17,7 @@ use super::{ vsettle, }; use crate::editor::is_word; -use crate::motion::{Backward, Forward, Reads, is_blank, is_break, left, right}; +use crate::motion::{Backward, Forward, Reads, WINDOW, is_blank, is_break, left, right}; use crate::vim_commands as ids; /// What an object's range is made of. @@ -298,23 +298,41 @@ fn word( Some(Span::Chars(back.offset()..end)) } -/// A bracket object from `p` with count `n`: the `n`th pair of `open` and -/// `close` out from the cursor. -fn pair( +/// How far a bracket object reads from where its scan starts, each way +/// (T-114): 1 MiB. A pair with a bracket further away counts as no pair. +pub(crate) const PAIR_SCAN: usize = 1 << 20; + +/// The text a bracket scan from `p` may read: from `p - PAIR_SCAN` up to, +/// not including, `p + PAIR_SCAN`. +fn scan_window(p: usize) -> (usize, usize) { + (p.saturating_sub(PAIR_SCAN), p.saturating_add(PAIR_SCAN)) +} + +/// The `n`th pair of `open` and `close` out from `p`, as the offsets of its +/// two brackets, with both inside `window`. With `on`, an opening bracket +/// at `p` is the first pair's, as for a cursor on it. Without, the scan +/// starts before `p` and the char at `p` doesn't count, as for the start of +/// a visual selection. +#[expect( + clippy::too_many_arguments, + reason = "each argument is one part of the scan" +)] +fn find_pair( buffer: &Buffer, reads: &mut Reads, p: usize, n: usize, - inner: bool, open: char, close: char, -) -> Option { + on: bool, + (floor, ceiling): (usize, usize), +) -> Option<(usize, usize)> { // The opening bracket: the one at `p`, or the `n`th unmatched one // before it. - let mut found = usize::from(char_at(buffer, reads, p) == Some(open)); + let mut found = usize::from(on && char_at(buffer, reads, p) == Some(open)); let mut o = p; if found < n { - let mut back = Backward::new(buffer, &mut reads.backward, p); + let mut back = Backward::floored(buffer, &mut reads.backward, p, floor); let depth = Cell::new(0usize); let keep = |c: char| { if c == close { @@ -337,7 +355,8 @@ fn pair( } // Its closing bracket. let after = o + open.len_utf8(); - let mut ahead = Forward::new(buffer, &mut reads.forward, after); + let budget = ceiling.saturating_sub(after); + let mut ahead = Forward::bounded(buffer, &mut reads.forward, after, WINDOW, budget); let depth = Cell::new(0usize); ahead.skip_while(|c| { if c == open { @@ -351,12 +370,31 @@ fn pair( true }); ahead.peek()?; - let c = ahead.offset(); - drop(ahead); - if !inner { - return Some(Span::Chars(o..c + close.len_utf8())); + Some((o, ahead.offset())) +} + +/// A bracket object from `p` with count `n`: the `n`th pair of `open` and +/// `close` out from the cursor. +fn pair( + buffer: &Buffer, + reads: &mut Reads, + p: usize, + n: usize, + inner: bool, + open: char, + close: char, +) -> Option { + let (o, c) = find_pair(buffer, reads, p, n, open, close, true, scan_window(p))?; + if inner { + inside(buffer, reads, o + open.len_utf8(), c) + } else { + Some(Span::Chars(o..c + close.len_utf8())) } +} +/// What `i` covers of the pair whose opening bracket ends at `after` and +/// whose closing bracket starts at `c`, or `None` if that is empty. +fn inside(buffer: &Buffer, reads: &mut Reads, after: usize, c: usize) -> Option { // A line break right after the opening bracket is left out. let mut start = after; let opens_a_line = char_at(buffer, reads, start).is_some_and(is_break); @@ -383,6 +421,41 @@ fn pair( Some(Span::Chars(start..end)) } +/// A bracket object from a visual selection longer than one char, whose +/// first char is at `lo` and last at `hi`, as Vim 9.1 does it (T-114). The +/// pair is the `n`th out from before `lo`, so an opening bracket at `lo` +/// isn't that pair's: `va(a(` grows to the next pair out. `a` selects that +/// pair. `i` selects its inside, and while that inside lies within the +/// selection and is more than one char, it moves out one pair, so `vi(i(` +/// grows too. Gives the new selection's first and last chars, in that +/// order, or `None` if there is no such pair. +pub(crate) fn grow_pair( + buffer: &Buffer, + reads: &mut Reads, + (lo, hi): (usize, usize), + object: VimObject, + count: Option, +) -> Option<(usize, usize)> { + let Kind::Pair { open, close } = object.kind else { + return None; + }; + let window = scan_window(lo); + let n = count.unwrap_or(1).max(1); + let (mut o, mut c) = find_pair(buffer, reads, lo, n, open, close, false, window)?; + loop { + if !object.inner { + let span = Span::Chars(o..c + close.len_utf8()); + return Some(visual_ends(buffer, reads, &span)); + } + let span = inside(buffer, reads, o + open.len_utf8(), c)?; + let (first, last) = visual_ends(buffer, reads, &span); + if first < lo || last > hi || first == last { + return Some((first, last)); + } + (o, c) = find_pair(buffer, reads, o, 1, open, close, false, window)?; + } +} + /// A quote object from `p` with count `n`, within `p`'s line. fn quote( buffer: &Buffer, @@ -432,7 +505,9 @@ fn quote( } count += 1; } - escaped = c == '\\'; + // A backslash escapes the char after it, another backslash too, so + // a quote is escaped after an odd number of them (T-114). + escaped = c == '\\' && !escaped; reader.advance(); } drop(reader); diff --git a/crates/helm-editor/src/vim.rs b/crates/helm-editor/src/vim.rs index 63a683e..382acb8 100644 --- a/crates/helm-editor/src/vim.rs +++ b/crates/helm-editor/src/vim.rs @@ -371,6 +371,26 @@ //! //! Visual-mode `d` and `c` weren't part of that run. //! +//! T-114 measured bracket objects from longer visual selections, escaped +//! quotes and the bracket scan's cap in the same Vim, and found these +//! differences. The first is Khakha's choice; the others follow the rules +//! above: +//! +//! - The bracket scan stops 1 MiB from where it starts and finds no pair +//! (Khakha's answer on PR #42). Vim reads the whole text, so `di(` with a +//! bracket 2 MiB away deletes in Vim and does nothing here. +//! - With no pair around the cursor, Vim looks for the next pair after +//! it, even on a later line, and here a bracket object finds nothing. +//! `di(` from `b` in `a b (c) d` leaves `a b () d` in Vim and changes +//! nothing here. In a visual mode Vim does the same when no pair is out +//! from the selection's start, and can select a pair inside the +//! selection: `va(a(a(` from `c` in `f(a(bc)d)e` leaves `(bc)` selected +//! in Vim, and `(a(bc)d)` stays selected here. +//! - With no unescaped quote before the cursor, Vim takes the line's first +//! quote as the opening one even if it is escaped. `di"` from `a` in +//! `x\"a"b"` leaves `x\""b"` in Vim. Here the escaped quote doesn't +//! count, so the pair is `"b"` and it leaves `x\"a""`. +//! //! # Visual-mode commands //! //! | Id | Keys | What it does | @@ -430,10 +450,15 @@ //! lines between, so `di{` on a block of lines leaves `{` and `}` on their //! own lines and `ci{` leaves one empty line to type in. When both are left //! out and one empty line is between them, `i` is that line. Any other -//! empty `i` finds nothing. All measured in Vim 9.1. -//! -//! **Quotes.** Only within the cursor's line. A quote right after a -//! backslash doesn't count. On a quote, its index among the line's quotes +//! empty `i` finds nothing. All measured in Vim 9.1. The scan reads at most +//! 1 MiB each way from where it starts (T-114): a pair counts only if both +//! its brackets are in the 1 MiB before that point or the 1 MiB from it on, +//! and a scan that reaches either end without its bracket finds no pair. +//! +//! **Quotes.** Only within the cursor's line. A quote right after an odd +//! number of backslashes doesn't count; after an even number, the +//! backslashes escape each other and the quote counts (T-114, as Vim 9.1 +//! does). On a quote, its index among the line's quotes //! says whether it opens or closes. Elsewhere, the quotes are the nearest //! one before the cursor and the nearest one after; with none before, the //! first pair after the cursor. `a` covers the quotes and the white space @@ -457,7 +482,13 @@ //! //! **In a visual mode** an object from a one-char selection replaces it, //! and from a longer one grows it from the visual cursor: `viwiw` adds the -//! next run. `ip` and `ap` switch to visual-line mode and the rest to +//! next run. A bracket object from a longer selection follows Vim 9.1 +//! instead (T-114). Its scan starts before the selection's first char, so +//! a bracket there isn't that pair's, and it gives the `n`th pair out: +//! `a` selects that pair, and `i` its inside, moving out one pair at a +//! time while the inside lies within the selection and is more than one +//! char. So `va(a(` and `vi(i(` grow to the next pair out. The selection +//! then runs forward, from the pair's first char to its last. `ip` and `ap` switch to visual-line mode and the rest to //! visual mode, by the binding's `then_mode`, even when the object finds //! nothing; then the selection doesn't change. A visual end is never the //! line break of a line with text (T-108), so an object range that ends diff --git a/crates/helm-editor/tests/vim_t114.rs b/crates/helm-editor/tests/vim_t114.rs new file mode 100644 index 0000000..fd93c0d --- /dev/null +++ b/crates/helm-editor/tests/vim_t114.rs @@ -0,0 +1,192 @@ +//! T-114's tests: Khakha's answers to PR #42's open questions on the bracket +//! scan's 1 MiB cap, repeated visual bracket objects and escaped quotes, +//! and a CRLF row for normal linewise `p` below a last line with no line +//! break. +//! +//! Every row that ends in normal mode with one cursor and no CR was run +//! through Vim 9.1 (`vim -u NONE -N -i NONE -n`, `binary`, `noeol`), and the +//! expected text and cursor are Vim's, except where a comment says +//! otherwise. Markers and key notation are as in `vim_harness`. + +mod vim_harness; + +use vim_harness::{Vim, table}; + +/// How far a bracket object reads each way from where its scan starts. +const MIB: usize = 1 << 20; + +#[test] +fn repeated_visual_bracket_objects_grow_to_the_next_pair_out() { + table(&[ + ("f(a(b|c)d)e", "va(a(d", "f|e"), + ("f(a(b|c)d)e", "vi(i(d", "f(|)e"), + ("f(a(b|c)d)e", "Va(a(d", "f|e"), + ("x {a {b|c} d} y", "va{a{d", "x | y"), + ("x [a [b|c] d] y", "vi[i[d", "x [|] y"), + ("x d> y", "viid", "x <|> y"), + ("f(a\n (b|c)\n d)e", "vi(i(d", "f(|)e"), + // Three levels, and a count on the second object. + ("((((|bc))))", "vi(i(i(d", "((|))"), + ("((((|bc))))", "vi(2i(d", "(((|)))"), + ("(((|b)))", "va(2a(d", "|"), + ("f(a(b|c)d)e", "vi(2i(d", "f(|)e"), + ]); +} + +#[test] +fn a_bracket_object_after_another_object_grows_past_it() { + table(&[ + // `a(` after `i(`: the pair around the inside. + ("f(a(b|c)d)e", "vi(a(d", "f(a|d)e"), + // `i(` after `a(`: the inside of the next pair out. + ("f(a(b|c)d)e", "va(i(d", "f(|)e"), + // With the visual cursor at the start. + ("f(a(b|c)d)e", "va(oa(d", "f|e"), + ("f(a(b|)c)", "vla(a(d", "|f"), + ]); +} + +#[test] +fn a_bracket_object_from_a_longer_selection_starts_at_its_first_char() { + table(&[ + ("f(a(b|cd)e)", "vla(d", "f(a|e)"), + ("f(a(bc|d)e)", "vhi(d", "f(a(|)e)"), + // The inside of `(bc)` doesn't cover `)`, so `i(` moves out. + ("f(a(|bc)d)", "vlli(d", "f(|)"), + // A closing bracket at the first char doesn't count. + ("f(a(b|)c)", "vli(d", "f(a(|)c)"), + // A selection that crosses a pair takes the pair around its start. + ("f(a(|b)c(d)e)", "v4la(d", "f(a|c(d)e)"), + // An inside of one char doesn't grow, even inside the selection. + ("f(a(|b)c(d)e)", "v4li(d", "f(a(|)c(d)e)"), + // A one-char selection is a fresh object. + ("((|b))", "vi(i(d", "((|))"), + ("f|(a(b)c)", "vi(i(d", "f(|)"), + ]); +} + +#[test] +fn a_grown_bracket_selection_runs_forward() { + // Vim always puts the visual cursor on the pair's last char. + let mut v = Vim::new("f(a(bc|d)e)"); + v.keys("vha("); + assert_eq!(v.show(), "f(a^(bcd)|e)"); + let mut v = Vim::new("f(a(b|c)d)e"); + v.keys("va(oa("); + assert_eq!(v.show(), "f^(a(bc)d)|e"); +} + +#[test] +fn a_grown_inner_block_of_lines_stops_before_the_line_break() { + // Vim selects through the line break after ` }`. A visual end here is + // never the line break of a line with text (T-108), so the selection + // stops on `}`. + let mut v = Vim::new("{\n {\n |x\n }\n}"); + v.keys("vi{i{"); + assert_eq!(v.show(), "{\n^ {\n x\n }|\n}"); +} + +#[test] +fn a_bracket_object_with_no_pair_out_keeps_the_selection() { + // Helm's rule: where the object finds nothing, the selection stays. + // Vim 9.1 instead leaves `(bc)` selected after the third `a(`, which + // `vim.rs` lists as a difference. + table(&[ + ("f(a(b|c)d)e", "va(a(a(d", "f|e"), + ("f(a(b|c)d)e", "vi(i(i(d", "f(|)e"), + ]); +} + +#[test] +fn a_quote_is_escaped_only_after_an_odd_number_of_backslashes() { + table(&[ + // Two backslashes escape each other, so the quote after them closes. + ("\"|a\\\\\"b\"", "di\"", "\"|\"b\""), + ("\"a\\\\|\"b\"", "di\"", "\"|\"b\""), + ("\"|a\\\\\\\\\"b\"", "di\"", "\"|\"b\""), + ("x\\\\\"|a\"b\"", "di\"", "x\\\\\"|\"b\""), + ("|x \\\\\"a\" b", "di\"", "x \\\\\"|\" b"), + ("\"a\\\\\" |x \"c\"", "di\"", "\"a\\\\\"|\"c\""), + ("\"|a\\\\\"", "di\"", "\"|\""), + ("\\\\\"|a\"", "di\"", "\\\\\"|\""), + ("'|a\\\\'b'", "di'", "'|'b'"), + ("`|a\\\\`b`", "di`", "`|`b`"), + ("\"|a\\\\\" b", "da\"", "|b"), + ("\"|a\\\\\"", "vi\"d", "\"|\""), + ("\"|a\\\\\"b\"", "ci\"X", "\"|X\"b\""), + // The cursor's quote is the third, so it opens a pair that never + // closes. + ("\"a\\\\\"|\"", "di\"", "\"a\\\\\"|\""), + ("\"a\\\\\"b|\"", "da\"", "\"a\\\\\"b|\""), + // One, three and five backslashes escape the quote. + ("\"|a\\\\\\\"b\"", "di\"", "\"|\""), + ("\"|a\\\\\\\\\\\"b\"", "di\"", "\"|\""), + ("s = \"a\\\"|b\";", "di\"", "s = \"|\";"), + ]); +} + +#[test] +fn an_escaped_quote_never_opens_a_pair() { + // Vim 9.1 leaves `x\""b"`: with no unescaped quote before the cursor, + // it takes the escaped one as the opening quote. `vim.rs` lists this + // as a difference. + table(&[("x\\\"|a\"b\"", "di\"", "x\\\"a\"|\"")]); +} + +#[test] +fn a_bracket_scan_reads_at_most_1_mib_before_the_cursor() { + // `(` at offset 0 and the cursor 1 MiB after it: just inside. + let text = format!("({}|b)", "a".repeat(MIB - 1)); + let mut v = Vim::new(&text); + v.keys("di("); + assert_eq!(v.text(), "()"); + // One byte further: just outside, so no pair. + let text = format!("({}|b)", "a".repeat(MIB)); + let mut v = Vim::new(&text); + v.keys("di("); + assert_eq!(v.text().len(), MIB + 3); +} + +#[test] +fn a_bracket_scan_reads_at_most_1_mib_from_the_cursor_on() { + // The cursor at offset 1 and `)` at 1 MiB: the last byte it may read. + let text = format!("(|b{})", "a".repeat(MIB - 2)); + let mut v = Vim::new(&text); + v.keys("di("); + assert_eq!(v.text(), "()"); + // One byte further: just outside, so no pair. + let text = format!("(|b{})", "a".repeat(MIB - 1)); + let mut v = Vim::new(&text); + v.keys("di("); + assert_eq!(v.text().len(), MIB + 2); +} + +#[test] +fn a_capped_scan_finds_no_outer_pair_for_a_count() { + // The inner pair is near, the outer one's `(` is past the cap. + let text = format!("({}(|b))", "a".repeat(MIB)); + let mut v = Vim::new(&text); + v.keys("d2i("); + assert_eq!(v.text().len(), MIB + 5); + v.keys("di("); + assert_eq!(v.text().len(), MIB + 4); +} + +#[test] +fn a_capped_scan_keeps_the_visual_selection() { + let text = format!("({}(|b))", "a".repeat(MIB)); + let mut v = Vim::new(&text); + v.keys("va(a(d"); + // `va(` selects `(b)`; the second `a(` finds no pair within the cap. + assert_eq!(v.text().len(), MIB + 2); +} + +#[test] +fn linewise_p_below_a_last_line_with_no_crlf_puts_one() { + // The register's CRLF moves in front of the put lines. + table(&[ + ("|a\r\nb", "yyjp", "a\r\nb\r\n|a"), + ("|a\r\nb", "yyj2p", "a\r\nb\r\n|a\r\na"), + ("a\r\n|b", "yyp", "a\r\nb\r\n|b"), + ]); +} From 4e04a277e2e42b29f74f455bb7edc6f6c36f2100 Mon Sep 17 00:00:00 2001 From: shubhook Date: Sat, 28 Nov 2026 17:45:16 +0530 Subject: [PATCH 3/9] editor: correct the EditorId and linewise put comments Refs: T-114 --- crates/helm-editor/src/editor.rs | 5 ++++- crates/helm-editor/src/editor/vim.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/helm-editor/src/editor.rs b/crates/helm-editor/src/editor.rs index 694287b..74661be 100644 --- a/crates/helm-editor/src/editor.rs +++ b/crates/helm-editor/src/editor.rs @@ -163,7 +163,10 @@ pub struct Editor { /// editor that made it, not to its buffer, since two editors can show one /// buffer. /// -/// The editor owns the only strong reference. A [`Session`](crate::Session) +/// The editor owns the only lasting strong reference: +/// [`CommandRegistry::run_in`](crate::CommandRegistry::run_in) holds a clone +/// while a command runs and drops it before it returns. A +/// [`Session`](crate::Session) /// keeps a [`Weak`] one with each open record, so it can tell which editor /// a record belongs to and, once that editor is dropped, that nobody will /// finish the record. The allocation outlives the editor while any weak diff --git a/crates/helm-editor/src/editor/vim.rs b/crates/helm-editor/src/editor/vim.rs index de038bd..1970918 100644 --- a/crates/helm-editor/src/editor/vim.rs +++ b/crates/helm-editor/src/editor/vim.rs @@ -883,7 +883,10 @@ impl Editor { } else { // Below a last line with no line break: the break moves // to the front. - // The text's own bytes are moved in place, not copied. + // The text stays in its own allocation: `split_off` + // copies only the line break, 1 or 2 bytes, into a + // small string, and `insert_str` shifts the rest of the + // text along to put the break in front. let mut text = text; let body = split_break(&text).0.len(); let end: String = text.split_off(body); From b34716f3a93d8e5429495c200a3f7134a4b705d2 Mon Sep 17 00:00:00 2001 From: shubhook Date: Sat, 28 Nov 2026 17:45:16 +0530 Subject: [PATCH 4/9] tasks: describe how T-109's two grants landed Refs: T-114 --- tasks/109-vim-objects.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tasks/109-vim-objects.md b/tasks/109-vim-objects.md index 234c428..1fdf5d8 100644 --- a/tasks/109-vim-objects.md +++ b/tasks/109-vim-objects.md @@ -81,10 +81,12 @@ pub const INNER_WORD, A_WORD, SELECT_INNER_WORD, SELECT_A_WORD, ...: &str; // 4 Two existing functions change, as their doc comments now say. `CommandRegistry::run` runs with a fresh `Session` and drops the requests, so T-106 to T-108's callers see no difference; it is already filled in. `Dispatcher::resolve` gains the register rule, the command-line rule (rule 5) and a pending register in rules 2 and 3, and `KeyState::cancel` drops a pending register and leaves the command line. Their code is unchanged in this PR except for one `todo!()` arm for `Action::Register`, which no existing binding reaches. Every T-101 to T-108 and T-110 test still passes. -### How this compiles without the two pending grants +### How the two grants landed -- **The register argument (open question 1).** `resolve` must hand the pending register to the command, and `.` must replay it. The natural place is a `CommandArgs::register` field, but adding one breaks the two `CommandArgs` literals in `tests/commands.rs` (lines 266 and 289). So this PR adds no field. The docs say where the register goes depends on question 1, and every test reaches registers only through keys and `Session::register`, never by naming the field. The tests hold whichever way question 1 goes. -- **T-108's pinned lists (open question 2).** `tests/vim_keymap.rs` pins `vim::keymap()` at six modes and 115 bindings, `vim_commands::ALL` at 55 ids (`[&str; 55]`) and `with_vim_commands()` at 91 commands. So this PR adds the 52 ids as constants outside `ALL`, documents the 391 bindings and two modes on `vim::keymap` as T-109's, and registers nothing. The new tests reach the keymap and registry through one helper, `tests/vim_harness/mod.rs`, which names `vim::keymap()` and `with_vim_commands()`. Under option (a) that helper stays; under option (b) its two lines name the new functions. +The spec PR compiled without either grant. Khakha granted both, and PR #42 (merged as `7638344`) made the edits in their own commit, `a6c9cff`: + +- **The register argument (question 1).** `CommandArgs::register: Option` holds the pending register, so `resolve` hands it to the command with the count and `.` replays it. The two `CommandArgs` literals in `tests/commands.rs` that open at lines 266 and 289 now end in `..CommandArgs::default()` in place of `count: None`. No assertion changed. +- **T-108's pinned lists (question 2, option (a)).** The T-109 ids, bindings and commands joined T-108's: `vim_commands::ALL` holds 107 ids, `with_vim_commands()` 143 commands, and `vim::keymap()` eight modes and 506 bindings. `tests/vim_keymap.rs` asserts those counts. `the_keymap_has_exactly_the_documented_bindings` compares the whole keymap with T-108's 115 rows, unchanged, followed by a `t109_documented()` list of the 391 new ones. `tests/vim_harness/mod.rs` still names `vim::keymap()` and `with_vim_commands()` once each, as before. ### What the existing code and tests allow From 31c2dcef2c6963dbda49d826fbf0704f99868809 Mon Sep 17 00:00:00 2001 From: shubhook Date: Sat, 28 Nov 2026 18:46:22 +0530 Subject: [PATCH 5/9] editor: check both brackets against the 1 MiB window 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 --- crates/helm-editor/src/motion/vim/object.rs | 11 ++- crates/helm-editor/src/vim.rs | 11 +-- crates/helm-editor/tests/vim_t114.rs | 78 +++++++++++++++++++++ 3 files changed, 92 insertions(+), 8 deletions(-) diff --git a/crates/helm-editor/src/motion/vim/object.rs b/crates/helm-editor/src/motion/vim/object.rs index 2f7317e..0c87ff3 100644 --- a/crates/helm-editor/src/motion/vim/object.rs +++ b/crates/helm-editor/src/motion/vim/object.rs @@ -5,8 +5,8 @@ //! Word objects read a window at a time from the cursor and stop at the //! line's ends. Quote objects read the cursor's line from its start. //! Bracket objects read outward from the cursor, at most 1 MiB each way, -//! and use the line index only for the block rule at the end. Paragraph objects use a fixed -//! number of line-index lookups per line they cross. +//! and use the line index only for the block rule at the end. Paragraph +//! objects use a fixed number of line-index lookups per line they cross. use std::cell::Cell; @@ -370,7 +370,12 @@ fn find_pair( true }); ahead.peek()?; - Some((o, ahead.offset())) + let c = ahead.offset(); + // A reader reads at least 4 bytes per window, so it can read a few + // bytes past its limit, and a window ends on a char boundary. So check + // both brackets against the window here. Any pair further out is also + // outside it, so this never drops a pair inside the window. + (o >= floor && c < ceiling).then_some((o, c)) } /// A bracket object from `p` with count `n`: the `n`th pair of `open` and diff --git a/crates/helm-editor/src/vim.rs b/crates/helm-editor/src/vim.rs index 382acb8..3084bc3 100644 --- a/crates/helm-editor/src/vim.rs +++ b/crates/helm-editor/src/vim.rs @@ -488,11 +488,12 @@ //! `a` selects that pair, and `i` its inside, moving out one pair at a //! time while the inside lies within the selection and is more than one //! char. So `va(a(` and `vi(i(` grow to the next pair out. The selection -//! then runs forward, from the pair's first char to its last. `ip` and `ap` switch to visual-line mode and the rest to -//! visual mode, by the binding's `then_mode`, even when the object finds -//! nothing; then the selection doesn't change. A visual end is never the -//! line break of a line with text (T-108), so an object range that ends -//! right after such a break selects up to the char before it. +//! then runs forward, from the pair's first char to its last. `ip` and +//! `ap` switch to visual-line mode and the rest to visual mode, by the +//! binding's `then_mode`, even when the object finds nothing; then the +//! selection doesn't change. A visual end is never the line break of a +//! line with text (T-108), so an object range that ends right after such +//! a break selects up to the char before it. //! //! # Registers (T-109) //! diff --git a/crates/helm-editor/tests/vim_t114.rs b/crates/helm-editor/tests/vim_t114.rs index fd93c0d..7681711 100644 --- a/crates/helm-editor/tests/vim_t114.rs +++ b/crates/helm-editor/tests/vim_t114.rs @@ -190,3 +190,81 @@ fn linewise_p_below_a_last_line_with_no_crlf_puts_one() { ("a\r\n|b", "yyp", "a\r\nb\r\n|b"), ]); } + +/// Whether `di(` from `marked` changes the text. +fn di_paren_deletes(marked: &str) -> bool { + let mut v = Vim::new(marked); + let before = v.text().len(); + v.keys("di("); + v.text().len() != before +} + +#[test] +fn a_bracket_just_before_the_window_never_counts() { + // The `(` is one byte before the window's first byte. The `x`s move + // the rope's chunk boundaries past the window's start, 1 to 3 bytes + // in for some `k`, where a reader's 4-byte minimum read used to reach + // the `(`. + for k in 940..1030 { + let text = format!("{}({}|b)", "x".repeat(k), "a".repeat(MIB)); + assert!(!di_paren_deletes(&text), "k = {k}"); + } +} + +#[test] +fn a_bracket_at_the_windows_end_never_counts() { + // The `)` is at the window's end, the first byte it excludes. + for k in 330..420 { + let text = format!( + "{}(|b{}){}", + "x".repeat(k), + "a".repeat(MIB - 1), + "y".repeat(2000) + ); + assert!(!di_paren_deletes(&text), "k = {k}"); + } +} + +#[test] +fn a_visual_bracket_object_never_grows_past_the_window() { + for k in 940..1030 { + let text = format!("{}({}(|b))", "x".repeat(k), "a".repeat(MIB)); + let mut v = Vim::new(&text); + v.keys("va(a(d"); + // `va(` selects `(b)`, and `a(` finds no pair within the window. + assert_eq!(v.text().len(), k + MIB + 2, "k = {k}"); + } +} + +#[test] +fn a_char_across_the_windows_end_doesnt_let_the_scan_past_it() { + // The window ends inside `é` or `中`, and `)` comes right after it. + for wide in ["é", "中"] { + let text = format!("(|b{}{wide})", "a".repeat(MIB - 2)); + assert!(!di_paren_deletes(&text), "{wide}"); + let text = format!("(|b{}{wide})", "a".repeat(MIB - 3)); + assert!(!di_paren_deletes(&text), "{wide}, one byte in"); + } + // A pair that fits stays a pair. + let text = format!("(|b{}é)", "a".repeat(MIB - 4)); + assert!(di_paren_deletes(&text)); +} + +#[test] +fn a_char_across_the_windows_start_doesnt_let_the_scan_past_it() { + // The window starts inside `é` or `中`, and `(` comes right before it. + for wide in ["é", "中"] { + for a in [MIB - 2, MIB - 1] { + let text = format!("({wide}{}|b)", "a".repeat(a)); + assert!(!di_paren_deletes(&text), "{wide}, {a}"); + } + } + // A pair that fits stays a pair. + let text = format!("(é{}|b)", "a".repeat(MIB - 3)); + assert!(di_paren_deletes(&text)); +} + +#[test] +fn a_backslash_ending_the_line_before_escapes_nothing() { + table(&[("a\\\n\"|b\"", "di\"", "a\\\n\"|\"")]); +} From 89c5bd18505c4cb764c94d490bbd69b7afc6a8b9 Mon Sep 17 00:00:00 2001 From: shubhook Date: Sat, 28 Nov 2026 18:46:22 +0530 Subject: [PATCH 6/9] tasks: record T-114's round 1 fix and tests Refs: T-114 --- tasks/114-t109-followups.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/114-t109-followups.md b/tasks/114-t109-followups.md index fa256c2..9a81ee7 100644 --- a/tasks/114-t109-followups.md +++ b/tasks/114-t109-followups.md @@ -31,7 +31,7 @@ None of 1 to 3 changes an existing test's assertion. Every existing test passes ## The work -1. **The bracket scan's cap.** A bracket object reads at most 1 MiB (`1 << 20` bytes) 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 lie from 1 MiB before that point up to, not including, 1 MiB after it. A scan that reaches either end without its bracket finds no pair. A count and a visual growth step share the same window. `vim.rs` lists the cap under "Measured against Vim". +1. **The bracket scan's cap.** A bracket object reads at most 1 MiB (`1 << 20` bytes) 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 lie from 1 MiB before that point up to, not including, 1 MiB after it. A scan that reaches either end without its bracket finds no pair. A count and a visual growth step share the same window. The readers read at least 4 bytes per window and end each window on a char boundary, so they can read up to 3 bytes past the window. So `find_pair` checks both brackets' offsets against the window before it returns a pair. `vim.rs` lists the cap under "Measured against Vim". 2. **Visual bracket objects from a longer selection.** Measured in Vim 9.1 (`vim -u NONE -N -i NONE -n`, `binary`, `noeol`), Vim's rule for a selection longer than one char is: - The scan starts before the selection's first char, so a bracket there isn't the pair's. The pair is the `n`th out from there. - `a` selects that pair. @@ -90,7 +90,7 @@ Each is listed under "Measured against Vim" in `vim.rs`: | File | What it proves | | --- | --- | -| `crates/helm-editor/tests/vim_t114.rs` (13, new) | Answers 2 and 3 with the Vim rows above, the cap with a pair just inside and just outside 1 MiB each way, a count and a visual growth stopped by the cap, the forward direction of a grown selection, the kept differences, and the CRLF row for `p`. Ten of the 13 fail on main at `7638344`. The three that pass there are the CRLF `p` test, the capped visual growth (main keeps that selection too) and the escaped quote that never opens a pair (main counts a single backslash too). | +| `crates/helm-editor/tests/vim_t114.rs` (19, new) | Answers 2 and 3 with the Vim rows above, the cap with a pair just inside and just outside 1 MiB each way, a count and a visual growth stopped by the cap, the forward direction of a grown selection, the kept differences, and the CRLF row for `p`. Six more come from council round 1: a bracket just outside the window at a rope chunk boundary on either side, a visual growth to an outer pair outside the window, a multi-byte char across either end of the window, and a backslash ending the line before a quote. Ten of the first 13 fail on main at `7638344`. The three that pass there are the CRLF `p` test, the capped visual growth (main keeps that selection too) and the escaped quote that never opens a pair (main counts a single backslash too). Of the six round 1 tests, four fail at `b34716f`. The window-start straddle and the line-end backslash pass there and guard against regressions. | Every existing test passes unchanged. From 012a0d46141b6057ee844189b5f0ea580c796acd Mon Sep 17 00:00:00 2001 From: shubhook Date: Sat, 28 Nov 2026 19:16:26 +0530 Subject: [PATCH 7/9] bench: say the no-pair benchmark scans the 1 MiB T-114 set 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 --- crates/helm-bench/benches/vim_objects.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/helm-bench/benches/vim_objects.rs b/crates/helm-bench/benches/vim_objects.rs index 7653867..d721dd9 100644 --- a/crates/helm-bench/benches/vim_objects.rs +++ b/crates/helm-bench/benches/vim_objects.rs @@ -8,7 +8,7 @@ //! //! `di_paren_no_pair_10mb` measures the worst case behind open question 6 //! of `tasks/109-vim-objects.md`: a bracket object with no enclosing pair -//! scans the text before the cursor to its start. +//! scans 1 MiB of the text before the cursor, the cap T-114 set. use std::hint::black_box; From e34271a0b29740f51a7b33d12b5309dee87103d7 Mon Sep 17 00:00:00 2001 From: shubhook Date: Sat, 28 Nov 2026 19:20:51 +0530 Subject: [PATCH 8/9] editor: make PAIR_SCAN private and note what the chunk tests rely on Council round 2 nits. No behaviour changes. Refs: T-114 --- crates/helm-editor/src/motion/vim/object.rs | 2 +- crates/helm-editor/tests/vim_t114.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/helm-editor/src/motion/vim/object.rs b/crates/helm-editor/src/motion/vim/object.rs index 0c87ff3..4914f5c 100644 --- a/crates/helm-editor/src/motion/vim/object.rs +++ b/crates/helm-editor/src/motion/vim/object.rs @@ -300,7 +300,7 @@ fn word( /// How far a bracket object reads from where its scan starts, each way /// (T-114): 1 MiB. A pair with a bracket further away counts as no pair. -pub(crate) const PAIR_SCAN: usize = 1 << 20; +const PAIR_SCAN: usize = 1 << 20; /// The text a bracket scan from `p` may read: from `p - PAIR_SCAN` up to, /// not including, `p + PAIR_SCAN`. diff --git a/crates/helm-editor/tests/vim_t114.rs b/crates/helm-editor/tests/vim_t114.rs index 7681711..65bc4a0 100644 --- a/crates/helm-editor/tests/vim_t114.rs +++ b/crates/helm-editor/tests/vim_t114.rs @@ -199,6 +199,12 @@ fn di_paren_deletes(marked: &str) -> bool { v.text().len() != before } +// The `k` ranges in the next three tests (940..1030 and 330..420) are +// tuned to where ropey puts chunk boundaries in these texts today. If +// helm-text's chunking changes, the tests still pass but may no longer +// put a chunk boundary 1 to 3 bytes inside the window. The `é` and `中` +// tests after them don't depend on chunks. + #[test] fn a_bracket_just_before_the_window_never_counts() { // The `(` is one byte before the window's first byte. The `x`s move From 1d11d5e22db9eef9e427f94c994c929010e2ef27 Mon Sep 17 00:00:00 2001 From: shubhook Date: Sat, 28 Nov 2026 19:27:21 +0530 Subject: [PATCH 9/9] tasks: record Khakha's answer on the bracket forward search Refs: T-114 --- tasks/114-t109-followups.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/114-t109-followups.md b/tasks/114-t109-followups.md index 9a81ee7..468dcc9 100644 --- a/tasks/114-t109-followups.md +++ b/tasks/114-t109-followups.md @@ -102,6 +102,6 @@ The doc comment of `crates/helm-bench/benches/vim_objects.rs` still says this be ## Out of scope -- Vim's forward search for a pair when none encloses the cursor. That is a question for Khakha. +- Vim's forward search for a pair when none encloses the cursor. Khakha asked for a follow-up task to follow it within the 1 MiB cap, and for this task to keep it as a listed difference. - Feedback for a refused put, a later `helm-ui` task (answer 4). - Visual ends on a line break, kept since T-108.