diff options
author | Blaž Hrastnik | 2021-02-24 08:29:28 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-02-25 07:49:30 +0000 |
commit | 01907b349771106865853dc2ea90aaa0913a7297 (patch) | |
tree | 42b0cb2288912148d7b86ba3ac55dadb5952d260 /helix-term | |
parent | 5fa1ba6b1c0a3ac4f93112b94be8477dc4d06b46 (diff) |
commands: Implement count for a few more commands.
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/commands.rs | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 2b8fe405..7d7ad0c9 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -128,8 +128,7 @@ pub fn move_line_start(cx: &mut Context) { pub fn move_next_word_start(cx: &mut Context) { let count = cx.count; let doc = cx.doc(); - // TODO: count - let pos = State::move_next_word_start(doc.text().slice(..), doc.selection().cursor()); + let pos = State::move_next_word_start(doc.text().slice(..), doc.selection().cursor(), count); doc.set_selection(Selection::point(pos)); } @@ -137,7 +136,7 @@ pub fn move_next_word_start(cx: &mut Context) { pub fn move_prev_word_start(cx: &mut Context) { let count = cx.count; let doc = cx.doc(); - let pos = State::move_prev_word_start(doc.text().slice(..), doc.selection().cursor()); + let pos = State::move_prev_word_start(doc.text().slice(..), doc.selection().cursor(), count); doc.set_selection(Selection::point(pos)); } @@ -169,11 +168,12 @@ pub fn move_file_end(cx: &mut Context) { pub fn extend_next_word_start(cx: &mut Context) { let count = cx.count; let doc = cx.doc(); - let mut selection = doc.selection().transform(|mut range| { - let pos = State::move_next_word_start(doc.text().slice(..), doc.selection().cursor()); + let selection = doc.selection().transform(|mut range| { + let pos = + State::move_next_word_start(doc.text().slice(..), doc.selection().cursor(), count); range.head = pos; range - }); // TODO: count + }); doc.set_selection(selection); } @@ -181,22 +181,23 @@ pub fn extend_next_word_start(cx: &mut Context) { pub fn extend_prev_word_start(cx: &mut Context) { let count = cx.count; let doc = cx.doc(); - let mut selection = doc.selection().transform(|mut range| { - let pos = State::move_prev_word_start(doc.text().slice(..), doc.selection().cursor()); + let selection = doc.selection().transform(|mut range| { + let pos = + State::move_prev_word_start(doc.text().slice(..), doc.selection().cursor(), count); range.head = pos; range - }); // TODO: count + }); doc.set_selection(selection); } pub fn extend_next_word_end(cx: &mut Context) { let count = cx.count; let doc = cx.doc(); - let mut selection = doc.selection().transform(|mut range| { + let selection = doc.selection().transform(|mut range| { let pos = State::move_next_word_end(doc.text().slice(..), doc.selection().cursor(), count); range.head = pos; range - }); // TODO: count + }); doc.set_selection(selection); } @@ -417,13 +418,13 @@ pub fn search_selection(cx: &mut Context) { // pub fn select_line(cx: &mut Context) { - // TODO: count + let count = cx.count; let doc = cx.doc(); let pos = doc.selection().primary(); let text = doc.text(); let line = text.char_to_line(pos.head); let start = text.line_to_char(line); - let end = text.line_to_char(line + 1).saturating_sub(1); + let end = text.line_to_char(line + count).saturating_sub(1); doc.set_selection(Selection::single(start, end)); } |