@@ -290,6 +290,7 @@ impl Command {
290290 join_selections, "Join lines inside selection",
291291 keep_selections, "Keep selections matching regex",
292292 keep_primary_selection, "Keep primary selection",
293+ remove_primary_selection, "Remove primary selection",
293294 completion, "Invoke completion popup",
294295 hover, "Show docs for item under cursor",
295296 toggle_comments, "Comment/uncomment selections",
@@ -4016,11 +4017,27 @@ fn keep_selections(cx: &mut Context) {
40164017
40174018fn keep_primary_selection(cx: &mut Context) {
40184019 let (view, doc) = current!(cx.editor);
4020+ // TODO: handle count
40194021
40204022 let range = doc.selection(view.id).primary();
40214023 doc.set_selection(view.id, Selection::single(range.anchor, range.head));
40224024}
40234025
4026+fn remove_primary_selection(cx: &mut Context) {
4027+ let (view, doc) = current!(cx.editor);
4028+ // TODO: handle count
4029+
4030+ let selection = doc.selection(view.id);
4031+ if selection.len() == 1 {
4032+ cx.editor.set_error("no selections remaining".to_owned());
4033+ return;
4034+ }
4035+ let index = selection.primary_index();
4036+ let selection = selection.clone().remove(index);
4037+
4038+ doc.set_selection(view.id, selection);
4039+}
4040+
40244041fn completion(cx: &mut Context) {
40254042 // trigger on trigger char, or if user calls it
40264043 // (or on word char typing??)