diff options
author | Matouš Dzivjak | 2021-12-29 09:17:46 +0000 |
---|---|---|
committer | GitHub | 2021-12-29 09:17:46 +0000 |
commit | bd2ab5be4331a2ab6d406378a9c0868eb2f72819 (patch) | |
tree | 04c09c72eea533540a1d3d1abd191b640a6a9ad0 /helix-core | |
parent | dc1faa35cbb92231c037241d01e25ae18ac36176 (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')
-rw-r--r-- | helix-core/src/selection.rs | 9 |
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 { |