Repository navigation
Move lines up and down with multiple selections - #8232
nathansobo merged 57 commits into
Conversation
|
cc @nathansobo I wonder if we can find the old specs for these methods. They may have been blown away inadvertently. |
|
I think we should probably just roll forward unless you want to go hunting. |
There was a problem hiding this comment.
In specs we typically use a shorter array-based notation: [[3, 2], [3, 9]]
There was a problem hiding this comment.
@nathansobo I noticed this is as well... but whenever I ran my tests they failed, asking for the specific range objects instead of the array style notation. I didn't know what else to do; but I did notice the array based styled used elsewhere
There was a problem hiding this comment.
Wow, that's odd. There may be some method that's not doing a Range.fromObject on its arguments and causing issues, but the equality checks should work. Could you try one more time with this particular assertion and if it doesn't work I'll investigate?
There was a problem hiding this comment.
Feeling a bit like the boy who cried wolf because I didn't have any problems using the array syntax today.. strange. changes made
|
❤️ Thanks for taking a crack at this. I'd like to see if we can simplify the implementation a bit with respect to fold handling, but this is a great start. |
|
@nathansobo I will spend some more time digging into the folds and possibly using screen coordinates. I didn't really investigate too deep when examining this as the main culprit that jumped out was that it just didn't use all the selected buffer ranges. |
220be3a to
81640af
Compare
|
@lpommers Checking in on this... you ready for another review? |
|
@nathansobo unfortunately not. I've spent a bit of time playing with using screen coordinates and am still having some trouble making it work with folds. When I come across a fold, instead of putting the row above it, it places it on the same line as the starting fold. Not sure why yet... |
|
Taking a deeper look here... you're definitely right that my initial suggestion of leaning heavily on screen coordinates isn't enough... folds will have to be dealt with explicitly. Which is a bummer. |
|
Okay, I've made some changes to your original PR for |
There was a problem hiding this comment.
@nathansobo here don't we want to refold at rangeToRefold.start.row - 1 instead? The fold has moved down after the insert, so its start row is now different. Creating the fold on the start row pushes the folding down one row too many. Same for the end row?

There was a problem hiding this comment.
@lpommers Definitely looks wrong, but I think we should correct the problem when we're originally pushing the range onto rangesToRefold. Would be good to add a spec that reproduces the behavior you've pictured.
|
@lpommers Ping me on this PR when you're ready for another review! |
…so as to return immediately if the first selection is at the start row
…rted order so none of the lines move if the bottom-most selection is at the last line
|
Some news, I fixed most issues with moving folded rows. As folds in I just have to fix the issue with scrolling when moving a wrapped line and it should be good for another 👀. |
…ple-selections Move lines up and down with multiple selections
|
@abe33 seeing some interesting behavior w/ folded rows on this branch now... are you seeing this? I've been experiencing some strange behavior on my local build recently, so it might just be my copy at the moment.. |
|
FYI, I just merged #9104, a small PR that adds autoindent when moving lines. It introduced a conflict with this branch, but it should be pretty easy to resolve. |
|
@lpommers Interesting, actually I'm not a heavy user of folds so I'm mostly working in the dark here, relying on tests to make sure I'm not missing anything, maybe we should use another grammar that js in the tests to make sure moving lines with folds operate smoothly in every cases. There's so many cases that it's hard to get the whole picture without a good set of tests. I think I'll try to add more tests using the cases you described to make sure I didn't missed some crucial factor. @maxbrunsfeld thanks for the heads up, I'll take some time tomorrow to review the PR with the new changes. |
|
@lpommers Are you sure you tried with a version of Atom running the branch? I can't reproduce either issues: |
|
@maxbrunsfeld as you had anticipated it was pretty easy to resolve, I took the liberty to moves the autoindent tests with the other line moves tests so that we don't need to look in several place in the future. As far as I can tell, the only remaining issue is when moving a wrapped line triggers a scroll. I'm looking into it now. |
|
Alright, the last issue was just that I was making the line two buffer rows below the selection visible instead of the selection row. I think we're pretty much done with this PR, if someone want to give it a look. @lpommers If you can merge lpommers#4 so that commits gets visible here. For the fun, here's an example of moving a multiple selection with a fold and autoindent enabled: ✨ |
|
👏 Nice! |
…ple-selections-2 Move lines up and down with multiple selections
|
Tested 👀 this locally and things are looking good. haven't been able to notice anything. 🙇 🙏 👏 to @abe33 for the work on this. And thanks to everyone else. not entirely sure what that build error is referring to though.. not sure what we can do about the license of a package? |
|
Yes, I just noticed that too, @50Wliu had identified the issue coming from atom/legal-eagle not expecting a parenthesis in the license string (https://github.com/atom/legal-eagle/blob/master/src/legal-eagle.coffee#L47-L56). |
…nd-down-with-multiple-selections
|
Just restarted the build since legal-eagle has been updated on master. Might take a while to complete though since I also restarted 3 others before this one. |
There was a problem hiding this comment.
📝 "intersection" -> "intersecting"
There was a problem hiding this comment.
Thank you for the heads up, I pushed a fix on @lpommers repo, it'll be available when he'll merge the branch.
…ple-selections Move lines up and down with multiple selections
|
@izuzak @nathansobo If you guys could give it a quick 👀 before we get too far from master again. The build failure is due to symbols-view whose tests was broken by language-javascript, as far as I can tell @50Wliu fixed that on master as. |
|
That was actually an accidental commit that I reverted. The failing symbols-view spec has been super-flaky for a long time now and can be safely ignored: atom/symbols-view#128. |
|
Insanely good job @lpommers, @abe33 and everyone else involved here. As mentioned, I have some ideas for improvements in core that could simplify this implementation, because it shouldn't be this hard. For now though, happy to have the feature. Edit: Props @izuzak as well for the awesome testing that kept this moving forward. |
…ltiple-selections Move lines up and down with multiple selections




Closes #2470
ctrl-cmd-upandctrl-cmd-downnow supports moving multiple selections up and down.