-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(commands): ensure_selections_forward #1393
Conversation
Add command that ensures that selections are in forward direction. Fixes: #1332
Add `A-:` keybinding for the ensure_selections_forward command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. Should we also update the flip_selections
command to make use of Range::flip
for consistency?
@dead10ck thanks for suggestion, done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
@@ -122,6 +122,15 @@ impl Range { | |||
} | |||
} | |||
|
|||
// flips the direction of the selection | |||
pub fn flip(&self) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Range is Copy
so self
can be used:
pub fn flip(&self) -> Self { | |
pub fn flip(self) -> Self { |
Doesn't seem to change the compiler output though. I also attempted to use
pub fn flip(mut self) -> Self {
std::mem::swap(&mut self.head, &mut self.anchor);
self
}
to see if it would generate better assembly but it ended up worse: https://rust.godbolt.org/z/rP8vva9G6
Add
ensure_selections_forward
command and bind it toA-:
by default.Fixes: #1332