-
-
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
Add command to merge consecutive ranges in selection #5047
Add command to merge consecutive ranges in selection #5047
Conversation
I think you can use |
0aa44ff
to
a08d407
Compare
I couldn't find a way to use |
The problem with this version is that you are potentially allocating a vector and copying all data. It might not be super critical but it is pretty easy to avoid here by using self.ranges.deadup_by(|prev_range, curr_range|{
if prev_range.to() == curr_range.from() {
*curr_range = curr_range.merge(curr_range);
// prev_range will be removed
true
} else {
false
}
}) |
Thanks for the help! I had missed the fact that |
Oh this is a nice implementation and we could simplify |
b60e9c7
to
7b0e8d3
Compare
Rewrote command, added test Moved keymap Refactoring command, added test coverage Added primary index calculation Moving primary_index calculation Refactored code to use fold instead of loop Changed to use dedup_by Removed duplicate merge call Fix primary index calculation
7b0e8d3
to
a0b7fd7
Compare
Simplified normalize the same way, happy to move it to a different PR if that would be better. |
Could you add a line for the new command to the book? Somewhere in this section would be good: Line 107 in aecb524
|
Added command to book, and renamed it to |
My attempt at #4914
Adds command that will merge consecutive ranges in the selection, bound to
Alt-_
for now.