on master help sign in
Add command for keeping only the primary selection.
commiteea339545cf7198b7a9e477ee2a9ee081ee5be36 authorBlaž Hrastnik <blaz@mxxn.io> dateMon 15 Mar 2021, 17:13 (6 years ago) parentdd91090
2 files changed+11
helix-term/src/commands.rs+8 helix-term/src/keymap.rs+3
helix-term/src/commands.rs+8
@@ -1167,6 +1167,14 @@ pub fn keep_selections(cx: &mut Context) {
11671167 cx.push_layer(Box::new(prompt));
11681168}
11691169
1170+pub fn keep_primary_selection(cx: &mut Context) {
1171+ let doc = cx.doc();
1172+
1173+ let range = doc.selection().primary();
1174+ let selection = Selection::single(range.anchor, range.head);
1175+ doc.set_selection(selection);
1176+}
1177+
11701178//
11711179
11721180pub fn save(cx: &mut Context) {
helix-term/src/keymap.rs+3
@@ -209,6 +209,9 @@ pub fn default() -> Keymaps {
209209 shift!('J') => commands::join_selections,
210210 // TODO: conflicts hover/doc
211211 shift!('K') => commands::keep_selections,
212+ // TODO: and another method for inverse
213+
214+ key!(' ') => commands::keep_primary_selection,
212215
213216 // key!('q') => commands::record_macro,
214217 // key!('Q') => commands::replay_macro,