@@ -2885,7 +2885,7 @@ pub mod insert {
2886 /// Exclude the cursor in range.
2886 /// Exclude the cursor in range.
2887 fn exclude_cursor(text: RopeSlice, range: Range, cursor: Range) -> Range {
2887 fn exclude_cursor(text: RopeSlice, range: Range, cursor: Range) -> Range {
2888− if range.to() == cursor.to() {
2888+ if range.to() == cursor.to() && text.len_chars() != cursor.to() {
2889 Range::new(
2889 Range::new(
2890 range.from(),
2890 range.from(),
2891 graphemes::prev_grapheme_boundary(text, cursor.to()),
2891 graphemes::prev_grapheme_boundary(text, cursor.to()),