aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-02-17 05:41:43 +0000
committerBlaž Hrastnik2021-02-17 08:26:27 +0000
commit9cac44c7c0f5696c8749fd8fdd32b8174723ab5d (patch)
treea884a5a2ca40a1fdb017a4c031996d9878860ab3 /helix-term
parent8e1a59c1408597484aeff7f96a09f1a1d10c76f6 (diff)
minor changes
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs6
-rw-r--r--helix-term/src/ui/editor.rs6
2 files changed, 7 insertions, 5 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 5cb47485..a2f8d20a 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -193,7 +193,7 @@ pub fn check_cursor_in_view(view: &View) -> bool {
let line = doc.text().char_to_line(cursor);
let document_end = view.first_line + view.area.height.saturating_sub(1) as usize;
- if (line > document_end.saturating_sub(PADDING)) | (line < view.first_line + PADDING) {
+ if (line > document_end.saturating_sub(PADDING)) || (line < view.first_line + PADDING) {
return false;
}
true
@@ -304,7 +304,9 @@ pub fn select_all(cx: &mut Context) {
pub fn select_regex(cx: &mut Context) {
let prompt = ui::regex_prompt(cx, "select:".to_string(), |doc, regex| {
let text = &doc.text().slice(..);
- let selection = selection::select_on_matches(text, doc.selection(), &regex);
+ // TODO: if select on matches returns empty range, we need to abort
+ let selection =
+ selection::select_on_matches(text, doc.selection(), &regex).expect("no matches");
doc.set_selection(selection);
});
cx.callback = Some(Box::new(
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 9383d1e1..22e80623 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -77,7 +77,7 @@ impl EditorView {
let range = {
// calculate viewport byte ranges
let start = text.line_to_byte(view.first_line);
- let end = text.line_to_byte(last_line) + text.line(last_line).len_bytes();
+ let end = text.line_to_byte(last_line + 1); // TODO: double check
start..end
};
@@ -381,8 +381,8 @@ impl Component for EditorView {
}
}
mode => {
- match keys.as_slice() {
- &[KeyEvent {
+ match *keys.as_slice() {
+ [KeyEvent {
code: KeyCode::Char(i @ '0'..='9'),
modifiers: KeyModifiers::NONE,
}] => {