aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorDylanBulfin2022-12-23 02:27:20 +0000
committerGitHub2022-12-23 02:27:20 +0000
commit1107296ca9bfd728258a4571be35eb7c811ff3b3 (patch)
treeb44b718366f56bc82a28f3d9d9305fdc312c151a /helix-term/src
parent1b89d3e5350f83b2ffb86a86326bd2714308ee53 (diff)
Add command to merge consecutive ranges in selection (#5047)
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs7
-rw-r--r--helix-term/src/keymap/default.rs1
2 files changed, 8 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 6cf49464..437e11b5 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -244,6 +244,7 @@ impl MappableCommand {
select_regex, "Select all regex matches inside selections",
split_selection, "Split selections on regex matches",
split_selection_on_newline, "Split selection on newlines",
+ merge_consecutive_selections, "Merge consecutive selections",
search, "Search for regex pattern",
rsearch, "Reverse search for regex pattern",
search_next, "Select next search match",
@@ -1589,6 +1590,12 @@ fn split_selection_on_newline(cx: &mut Context) {
doc.set_selection(view.id, selection);
}
+fn merge_consecutive_selections(cx: &mut Context) {
+ let (view, doc) = current!(cx.editor);
+ let selection = doc.selection(view.id).clone().merge_consecutive_ranges();
+ doc.set_selection(view.id, selection);
+}
+
#[allow(clippy::too_many_arguments)]
fn search_impl(
editor: &mut Editor,
diff --git a/helix-term/src/keymap/default.rs b/helix-term/src/keymap/default.rs
index ebcd125a..ef93dee0 100644
--- a/helix-term/src/keymap/default.rs
+++ b/helix-term/src/keymap/default.rs
@@ -76,6 +76,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
"s" => select_regex,
"A-s" => split_selection_on_newline,
+ "A-_" => merge_consecutive_selections,
"S" => split_selection,
";" => collapse_selection,
"A-;" => flip_selections,