From 77d75d92752835e2953b4a70f7ee8a9aeaff9fa0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= <blaz@mxxn.io>
Date: Thu, 1 Oct 2020 18:44:46 +0900
Subject: [PATCH] Collapse cursors command (;).

---
 helix-view/src/commands.rs | 7 +++++++
 helix-view/src/keymap.rs   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/helix-view/src/commands.rs b/helix-view/src/commands.rs
index 93ec2632..1fb9c90e 100644
--- a/helix-view/src/commands.rs
+++ b/helix-view/src/commands.rs
@@ -168,6 +168,13 @@ pub fn change_selection(view: &mut View, count: usize) {
     insert_mode(view, count);
 }
 
+pub fn collapse_selection(view: &mut View, _count: usize) {
+    view.state.selection = view
+        .state
+        .selection
+        .transform(|range| Range::new(range.head, range.head))
+}
+
 // insert mode:
 // first we calculate the correct cursors/selections
 // then we just append at each cursor
diff --git a/helix-view/src/keymap.rs b/helix-view/src/keymap.rs
index c5bce85a..d4ab85a2 100644
--- a/helix-view/src/keymap.rs
+++ b/helix-view/src/keymap.rs
@@ -134,6 +134,7 @@ pub fn default() -> Keymaps {
                 vec![key!('d')] => commands::delete_selection,
                 vec![key!('c')] => commands::change_selection,
                 vec![key!('s')] => commands::split_selection_on_newline,
+                vec![key!(';')] => commands::collapse_selection,
                 vec![Key {
                     code: KeyCode::Esc,
                     modifiers: Modifiers::NONE