summaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/state.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/helix-core/src/state.rs b/helix-core/src/state.rs
index 7cecba29..ffe88c3f 100644
--- a/helix-core/src/state.rs
+++ b/helix-core/src/state.rs
@@ -159,10 +159,9 @@ impl State {
(Direction::Forward, Granularity::Character) => {
// Clamp to line
let line = text.char_to_line(pos);
- let start = text.line_to_char(line);
- let len = text.line(line).len_chars();
- // convert to 0-indexed, subtract another 1 because len_chars() counts \n
- let end = start + len.saturating_sub(2);
+ // Line end is pos at the start of next line - 1
+ // subtract another 1 because the line ends with \n
+ let end = text.line_to_char(line + 1).saturating_sub(2);
std::cmp::min(nth_next_grapheme_boundary(&text.slice(..), pos, count), end)
}
(Direction::Forward, Granularity::Word) => {