aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/commands.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-10-07 09:31:04 +0000
committerBlaž Hrastnik2020-10-13 14:13:56 +0000
commita5be718dc61ffcc7c3d3af10e3f175359c7cc562 (patch)
treeefdd93b69739f2faf6a0803df4dcb3263a4bf46f /helix-view/src/commands.rs
parent809827967687ea7e6b645e7a9a60f9c523250578 (diff)
x for line selection
Diffstat (limited to 'helix-view/src/commands.rs')
-rw-r--r--helix-view/src/commands.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/helix-view/src/commands.rs b/helix-view/src/commands.rs
index ca1e41c4..f2bc3500 100644
--- a/helix-view/src/commands.rs
+++ b/helix-view/src/commands.rs
@@ -235,6 +235,18 @@ pub fn split_selection_on_newline(view: &mut View, _count: usize) {
view.state.selection = selection::split_on_matches(text, view.state.selection(), &REGEX)
}
+pub fn select_line(view: &mut View, _count: usize) {
+ // TODO: count
+ let pos = view.state.selection().primary();
+ let text = view.state.doc();
+ let line = text.char_to_line(pos.head);
+ let start = text.line_to_char(line);
+ let end = text.line_to_char(line + 1);
+
+ // TODO: use a transaction
+ view.state.selection = Selection::single(start, end);
+}
+
pub fn delete_selection(view: &mut View, _count: usize) {
let transaction =
Transaction::change_by_selection(&view.state, |range| (range.from(), range.to(), None));