Use `Range::line_range()` in some more places I missed.

imgbot
Nathan Vegdahl 3 years ago
parent 7d07704e6f
commit 673338bdb6

@ -3238,8 +3238,7 @@ fn get_lines(doc: &Document, view_id: ViewId) -> Vec<usize> {
// Get all line numbers // Get all line numbers
for range in doc.selection(view_id) { for range in doc.selection(view_id) {
let start = doc.text().char_to_line(range.from()); let (start, end) = range.line_range(doc.text().slice(..));
let end = doc.text().char_to_line(range.to());
for line in start..=end { for line in start..=end {
lines.push(line) lines.push(line)
@ -3367,10 +3366,9 @@ fn join_selections(cx: &mut Context) {
let fragment = Tendril::from(" "); let fragment = Tendril::from(" ");
for selection in doc.selection(view.id) { for selection in doc.selection(view.id) {
let start = text.char_to_line(selection.from()); let (start, mut end) = selection.line_range(slice);
let mut end = text.char_to_line(selection.to());
if start == end { if start == end {
end += 1 end = (end + 1).min(text.len_lines() - 1);
} }
let lines = start..end; let lines = start..end;

Loading…
Cancel
Save