From bd2ab5be4331a2ab6d406378a9c0868eb2f72819 Mon Sep 17 00:00:00 2001 From: Matouš Dzivjak Date: Wed, 29 Dec 2021 10:17:46 +0100 Subject: 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--- helix-core/src/selection.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'helix-core') 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 { -- cgit v1.2.3-70-g09d2