on master help sign in
Add command for keeping only the primary selection.
eea3395Blaž Hrastnik
helix-term/src/commands.rs+8
@@ -1167,6 +1167,14 @@ pub fn keep_selections(cx: &mut Context) {
1167 cx.push_layer(Box::new(prompt));
1167 cx.push_layer(Box::new(prompt));
1168}
1168}
1169
1169
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+
1170//
1178//
1171
1179
1172pub fn save(cx: &mut Context) {
1180pub fn save(cx: &mut Context) {
helix-term/src/keymap.rs+3
@@ -209,6 +209,9 @@ pub fn default() -> Keymaps {
209 shift!('J') => commands::join_selections,
209 shift!('J') => commands::join_selections,
210 // TODO: conflicts hover/doc
210 // TODO: conflicts hover/doc
211 shift!('K') => commands::keep_selections,
211 shift!('K') => commands::keep_selections,
212+ // TODO: and another method for inverse
213+
214+ key!(' ') => commands::keep_primary_selection,
212
215
213 // key!('q') => commands::record_macro,
216 // key!('q') => commands::record_macro,
214 // key!('Q') => commands::replay_macro,
217 // key!('Q') => commands::replay_macro,