diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 7ab3548afea87..f4c52f7af0581 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2892,7 +2892,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()),