aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs6
-rw-r--r--helix-term/src/ui/editor.rs2
-rw-r--r--helix-term/src/ui/prompt.rs2
3 files changed, 6 insertions, 4 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));
}
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index f474cb36..6c39088e 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -341,7 +341,7 @@ impl EditorView {
let info: Style = theme.get("info");
let hint: Style = theme.get("hint");
- for (i, line) in (view.first_line..last_line).enumerate() {
+ for (i, line) in (view.first_line..=last_line).enumerate() {
use helix_core::diagnostic::Severity;
if let Some(diagnostic) = doc.diagnostics.iter().find(|d| d.line == line) {
surface.set_stringn(
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index 1f424878..cdf303b8 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -114,7 +114,7 @@ impl Prompt {
let selected_color = theme.get("ui.menu.selected");
// completion
- let max_col = area.width / BASE_WIDTH;
+ let max_col = std::cmp::max(1, area.width / BASE_WIDTH);
let height = ((self.completion.len() as u16 + max_col - 1) / max_col);
let completion_area = Rect::new(
area.x,