diff options
author | Nathan Vegdahl | 2021-07-22 17:50:12 +0000 |
---|---|---|
committer | Nathan Vegdahl | 2021-07-22 17:50:12 +0000 |
commit | 673338bdb6064ff98e8822a251fd31664909610d (patch) | |
tree | ab697fb51690b7e3d382f789ecfcce2bb4e5e508 | |
parent | 7d07704e6ff59ed2eee664bb14e9c6a8c42ee4fb (diff) |
Use `Range::line_range()` in some more places I missed.
-rw-r--r-- | helix-term/src/commands.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 35a67e36..a17245aa 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3238,8 +3238,7 @@ fn get_lines(doc: &Document, view_id: ViewId) -> Vec<usize> { // Get all line numbers for range in doc.selection(view_id) { - let start = doc.text().char_to_line(range.from()); - let end = doc.text().char_to_line(range.to()); + let (start, end) = range.line_range(doc.text().slice(..)); for line in start..=end { lines.push(line) @@ -3367,10 +3366,9 @@ fn join_selections(cx: &mut Context) { let fragment = Tendril::from(" "); for selection in doc.selection(view.id) { - let start = text.char_to_line(selection.from()); - let mut end = text.char_to_line(selection.to()); + let (start, mut end) = selection.line_range(slice); if start == end { - end += 1 + end = (end + 1).min(text.len_lines() - 1); } let lines = start..end; |