diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index d5fc1ad934eb..94b77210dfdc 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2880,7 +2880,7 @@ pub mod insert { /// Exclude the cursor in range. fn exclude_cursor(text: RopeSlice, range: Range, cursor: Range) -> Range { - if range.to() == cursor.to() { + if range.to() == cursor.to() && text.len_chars() != cursor.to() { Range::new( range.from(), graphemes::prev_grapheme_boundary(text, cursor.to()),