From d2988ffc779e74afc8b03e83d51284afb165aa88 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 18 Nov 2025 14:02:40 +0100 Subject: [PATCH] vim: Fix snapshot out of bounds indexing (#42969) Fixes ZED-38X Release Notes: - N/A --- 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;