rope: Improve panic message for out of bounds anchor_at_offset (#40256)

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-10-15 14:36:58 +00:00
committed by GitHub
parent c814b99fcb
commit 85c2dc909d
2 changed files with 10 additions and 1 deletions
+3 -1
View File
@@ -2400,7 +2400,9 @@ impl BufferSnapshot {
} else if bias == Bias::Right && offset == self.len() {
Anchor::MAX
} else {
if !self.visible_text.is_char_boundary(offset) {
if offset > self.visible_text.len() {
panic!("offset {} is out of bounds", offset)
} else if !self.visible_text.is_char_boundary(offset) {
// find the character
let char_start = self.visible_text.floor_char_boundary(offset);
// `char_start` must be less than len and a char boundary