aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/application.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 82bba076..f9789d79 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -324,17 +324,21 @@ impl Application {
.unwrap();
let (view, doc) = current!(self.editor);
- log::info!("{:?}", doc);
- let start = doc.text().line_to_char(line - 1) + column;
+
+ let text_end = doc.text().len_chars() - 1;
+ let start = doc.text().try_line_to_char(line - 1).unwrap_or(0) + column;
if let Some(end_line) = end_line {
- let end =
- doc.text().line_to_char(end_line - 1) + end_column.unwrap_or(0);
+ let end = doc.text().try_line_to_char(end_line - 1).unwrap_or(0)
+ + end_column.unwrap_or(0);
doc.set_selection(
view.id,
- Selection::new(smallvec![Range::new(start, end)], 0),
+ Selection::new(
+ smallvec![Range::new(start.min(text_end), end.min(text_end))],
+ 0,
+ ),
);
} else {
- doc.set_selection(view.id, Selection::point(start));
+ doc.set_selection(view.id, Selection::point(start.min(text_end)));
}
align_view(doc, view, Align::Center);
}