From 4882f4d03d31995649645d3364ce68f85c90ca25 Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Wed, 19 Nov 2025 14:26:19 +0000 Subject: [PATCH] vim: Fix snapshot out of bounds indexing (#42969) (cherry-pick to preview) (#43068) Cherry-pick of #42969 to preview ---- Fixes ZED-38X Release Notes: - N/A Co-authored-by: Lukas Wirth --- crates/vim/src/normal/increment.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/vim/src/normal/increment.rs b/crates/vim/src/normal/increment.rs index 888d9ff25b63fad2e7fc0cf6cf534bfb1a7aaf76..7eadf5053a15f33946031a332cb8a7f2dcb8ed52 100644 --- a/crates/vim/src/normal/increment.rs +++ b/crates/vim/src/normal/increment.rs @@ -211,7 +211,7 @@ fn find_target( let mut pre_char = String::new(); // Backward scan to find the start of the number, but stop at start_offset - for ch in snapshot.reversed_chars_at(offset + 1) { + for ch in snapshot.reversed_chars_at(offset + if offset < snapshot.len() { 1 } else { 0 }) { // Search boundaries if offset == 0 || ch.is_whitespace() || (need_range && offset <= start_offset) { break;