on master help sign in
x for line selection
commita5be718dc61ffcc7c3d3af10e3f175359c7cc562 authorBlaž Hrastnik <blaz@mxxn.io> dateWed 7 Oct 2020, 18:31 (6 years ago) parent8098279
2 files changed+13
helix-view/src/commands.rs+12 helix-view/src/keymap.rs+1
helix-view/src/commands.rs+12
@@ -235,6 +235,18 @@ pub fn split_selection_on_newline(view: &mut View, _count: usize) {
235235 view.state.selection = selection::split_on_matches(text, view.state.selection(), &REGEX)
236236}
237237
238+pub fn select_line(view: &mut View, _count: usize) {
239+ // TODO: count
240+ let pos = view.state.selection().primary();
241+ let text = view.state.doc();
242+ let line = text.char_to_line(pos.head);
243+ let start = text.line_to_char(line);
244+ let end = text.line_to_char(line + 1);
245+
246+ // TODO: use a transaction
247+ view.state.selection = Selection::single(start, end);
248+}
249+
238250pub fn delete_selection(view: &mut View, _count: usize) {
239251 let transaction =
240252 Transaction::change_by_selection(&view.state, |range| (range.from(), range.to(), None));
helix-view/src/keymap.rs+1
@@ -145,6 +145,7 @@ pub fn default() -> Keymaps {
145145 vec![key!('c')] => commands::change_selection,
146146 vec![key!('s')] => commands::split_selection_on_newline,
147147 vec![key!(';')] => commands::collapse_selection,
148+ vec![key!('x')] => commands::select_line,
148149 vec![key!('u')] => commands::undo,
149150 vec![shift!('U')] => commands::redo,
150151 vec![key!('y')] => commands::yank,