Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

vim: Fix snapshot out of bounds indexing (#42969)

Lukas Wirthd2988ffc779e
diff --git a/crates/vim/src/normal/increment.rs b/crates/vim/src/normal/increment.rs
index 888d9ff25b6..7eadf5053a1 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;