From 1a772d1b67d4895d79273b027b1b1f86bd1616fe Mon Sep 17 00:00:00 2001
From: Jonathan LEI <me@xjonathan.dev>
Date: Wed, 19 Oct 2022 08:53:58 +0800
Subject: [PATCH] Fix deleting word from end of buffer (#4328)

---
 helix-term/src/commands.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 318dd035..5073651b 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -2885,7 +2885,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()),