aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/selection.rs
diff options
context:
space:
mode:
authorMatouš Dzivjak2021-12-29 09:17:46 +0000
committerGitHub2021-12-29 09:17:46 +0000
commitbd2ab5be4331a2ab6d406378a9c0868eb2f72819 (patch)
tree04c09c72eea533540a1d3d1abd191b640a6a9ad0 /helix-core/src/selection.rs
parentdc1faa35cbb92231c037241d01e25ae18ac36176 (diff)
feat(commands): ensure_selections_forward (#1393)
* feat(commands): ensure_selections_forward Add command that ensures that selections are in forward direction. Fixes: https://github.com/helix-editor/helix/issues/1332 * Add keybinding for ensure_selections_forward Add `A-:` keybinding for the ensure_selections_forward command. * Re-use range.flip for flip_selections command
Diffstat (limited to 'helix-core/src/selection.rs')
-rw-r--r--helix-core/src/selection.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/helix-core/src/selection.rs b/helix-core/src/selection.rs
index 884c98ac..06ea9d67 100644
--- a/helix-core/src/selection.rs
+++ b/helix-core/src/selection.rs
@@ -122,6 +122,15 @@ impl Range {
}
}
+ // flips the direction of the selection
+ pub fn flip(&self) -> Self {
+ Self {
+ anchor: self.head,
+ head: self.anchor,
+ horiz: self.horiz,
+ }
+ }
+
/// Check two ranges for overlap.
#[must_use]
pub fn overlaps(&self, other: &Self) -> bool {