Skip to content
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

Merged
merged 3 commits into from
Dec 29, 2021
Merged

feat(commands): ensure_selections_forward #1393

merged 3 commits into from
Dec 29, 2021

Conversation

matoous
Copy link
Contributor

@matoous matoous commented Dec 27, 2021

Add ensure_selections_forward command and bind it to A-: by default.

Fixes: #1332

Add command that ensures that selections are in forward direction.

Fixes: #1332
Add `A-:` keybinding for the ensure_selections_forward command.
Copy link
Member

@dead10ck dead10ck left a 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?

@matoous
Copy link
Contributor Author

matoous commented Dec 28, 2021

@dead10ck thanks for suggestion, done.

Copy link
Member

@dead10ck dead10ck left a 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 {
Copy link
Member

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:

Suggested change
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

@archseer archseer merged commit bd2ab5b into helix-editor:master Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ensure_selections key to ensure selections are in forward direction
3 participants