Files
zed/crates
Parker Loflin 7b5cc722a1 vim: Fix substitute without the g flag replacing the wrong matches (#67015)
## Summary

`SearchQuery::search` searches a slice of the buffer and returns offsets
into that slice. With `one_match_per_line`, it found each match's row by
passing the slice offset to `buffer.offset_to_point`, which takes a
buffer offset. When the slice started after the first line, matches got
the rows of lines nearer the top of the buffer, so the wrong matches
were kept. It now adds `range_offset`.

Only Vim's `:s` sets `one_match_per_line`, when it replaces the first
match on each line. It searches only the lines in its range, so it was
correct only when the range started on the first line. With `x` on line
1 and `aaaa` on line 2, `:s/a/b/` on line 2 gave `baba` instead of
`baaa`.

## Testing

- `test_replace_without_g_after_first_line` is new and fails without the
fix.
- `cargo test -p vim --lib` and `cargo test -p search --lib` pass.
- `cargo test -p project --features test-support --test integration
search` passes.
- `./script/clippy -p project -p vim` passes.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- Fixed Vim's `:s` without the `g` flag replacing the wrong matches when
used after the first line

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
2026-11-16 16:03:37 +00:00
..
…
2026-11-11 19:41:39 +00:00
…
2026-10-19 14:16:08 +00:00
2026-10-26 13:46:57 +00:00
…
…
…
…
…