From 376e9585696bd50b5352e0a971dc032fa065f61d Mon Sep 17 00:00:00 2001 From: Jordi Villar Date: Mon, 19 Jan 2026 09:08:45 +0100 Subject: [PATCH] Fix inverted char boundary check causing invalid offsets (#47112) The logic in `anchor_at_offset` and `to_offset` seems inverted when checking character boundaries. `assert_char_boundary` returns `true` when the offset IS valid, but the code was adjusting offsets when the function returned `true` (valid) instead of `false` (invalid). Release Notes: - N/A --- crates/text/src/text.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/text/src/text.rs b/crates/text/src/text.rs index 87ce4d49c14732c2a89d226e34026c7a8c37db6b..5c78f9aea606d2f3eb828643e660a1b41d65e755 100644 --- a/crates/text/src/text.rs +++ b/crates/text/src/text.rs @@ -2417,7 +2417,7 @@ impl BufferSnapshot { { Anchor::max_for_buffer(self.remote_id) } else { - if self + if !self .visible_text .assert_char_boundary::<{ cfg!(debug_assertions) }>(offset) { @@ -3125,7 +3125,7 @@ impl ToOffset for Point { impl ToOffset for usize { #[track_caller] fn to_offset(&self, snapshot: &BufferSnapshot) -> usize { - if snapshot + if !snapshot .as_rope() .assert_char_boundary::<{ cfg!(debug_assertions) }>(*self) {