Add command for keeping only the primary selection.

This commit is contained in:
Blaž Hrastnik 2021-03-15 17:13:36 +09:00
parent dd91090a1a
commit eea339545c
2 changed files with 11 additions and 0 deletions

View File

@ -1167,6 +1167,14 @@ pub fn keep_selections(cx: &mut Context) {
cx.push_layer(Box::new(prompt));
}
pub fn keep_primary_selection(cx: &mut Context) {
let doc = cx.doc();
let range = doc.selection().primary();
let selection = Selection::single(range.anchor, range.head);
doc.set_selection(selection);
}
//
pub fn save(cx: &mut Context) {

View File

@ -209,6 +209,9 @@ pub fn default() -> Keymaps {
shift!('J') => commands::join_selections,
// TODO: conflicts hover/doc
shift!('K') => commands::keep_selections,
// TODO: and another method for inverse
key!(' ') => commands::keep_primary_selection,
// key!('q') => commands::record_macro,
// key!('Q') => commands::replay_macro,