diff options
author | Kirawi | 2021-06-05 03:49:19 +0000 |
---|---|---|
committer | GitHub | 2021-06-05 03:49:19 +0000 |
commit | c17dcb8633550a4efde56ca5b4e2b00fbf9f45e1 (patch) | |
tree | 9ab71f76679c1735f275448768c091219e2d49c0 /helix-term/src/commands.rs | |
parent | 5a344a3ae508f571ad5427e14ffad683213bf142 (diff) |
Fixing Multiple Panics (#121)
* init
* wip
* wip
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r-- | helix-term/src/commands.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index bc11d0fe..12ec5e19 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -669,7 +669,7 @@ fn _search(doc: &mut Document, view: &mut View, contents: &str, regex: &Regex, e return; } - let head = end - 1; + let head = end; let selection = if extend { selection.clone().push(Range::new(start, head)) @@ -749,7 +749,9 @@ pub fn select_line(cx: &mut Context) { let line = text.char_to_line(pos.head); let start = text.line_to_char(line); - let end = text.line_to_char(line + count).saturating_sub(1); + let end = text + .line_to_char(std::cmp::min(doc.text().len_lines(), line + count)) + .saturating_sub(1); doc.set_selection(view.id, Selection::single(start, end)); } |