Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Move lines up and down with multiple selections - #8232

Merged
nathansobo merged 57 commits into
atom:masterfrom
lpommers:move-lines-up-and-down-with-multiple-selections
Nov 7, 2015
Merged

nathansobo merged 57 commits into
atom:masterfrom
lpommers:move-lines-up-and-down-with-multiple-selections

Conversation

@lpommers

@lpommers lpommers commented Aug 5, 2015

Copy link
Copy Markdown

Closes #2470

move-line

ctrl-cmd-up and ctrl-cmd-down now supports moving multiple selections up and down.

@mnquintana mnquintana self-assigned this Aug 5, 2015
@benogle

benogle commented Aug 5, 2015

Copy link
Copy Markdown
Contributor

cc @nathansobo I wonder if we can find the old specs for these methods. They may have been blown away inadvertently.

@mnquintana mnquintana removed their assignment Aug 5, 2015
@nathansobo

Copy link
Copy Markdown
Contributor

I think we should probably just roll forward unless you want to go hunting.

Comment thread spec/text-editor-spec.coffee Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In specs we typically use a shorter array-based notation: [[3, 2], [3, 9]]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feeling a bit like the boy who cried wolf because I didn't have any problems using the array syntax today.. strange. changes made

@nathansobo

Copy link
Copy Markdown
Contributor

❤️ 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.

@lpommers

lpommers commented Aug 6, 2015

Copy link
Copy Markdown
Author

@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.

@lpommers
lpommers force-pushed the move-lines-up-and-down-with-multiple-selections branch from 220be3a to 81640af Compare August 6, 2015 19:59
@nathansobo

Copy link
Copy Markdown
Contributor

@lpommers Checking in on this... you ready for another review?

@lpommers

Copy link
Copy Markdown
Author

@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...

@lpommers lpommers closed this Aug 11, 2015
@lpommers lpommers reopened this Aug 11, 2015
@nathansobo

Copy link
Copy Markdown
Contributor

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.

@nathansobo

Copy link
Copy Markdown
Contributor

Okay, I've made some changes to your original PR for moveLineUp in this PR. Would you be interested in taking a look at my adjustments and if you're in favor, add them to this PR and apply a similar treatment to moveLineDown?

Comment thread src/text-editor.coffee

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?
refold

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@nathansobo

Copy link
Copy Markdown
Contributor

@lpommers Ping me on this PR when you're ready for another review!

Luke Pommersheim added 5 commits August 13, 2015 18:02
@abe33

abe33 commented Nov 3, 2015

Copy link
Copy Markdown
Contributor

Some news, I fixed most issues with moving folded rows. As folds in rangesToFold were not destroyed there was a lot of side effects when moving multiple selections containing folds and close enough that one selection was refolding the previously moved fold (but still present in the display buffer as it wasn't destroyed) with wrong coordinates.

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
@lpommers

lpommers commented Nov 3, 2015

Copy link
Copy Markdown
Author

@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..

fols
fols2

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

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.

@abe33

abe33 commented Nov 3, 2015

Copy link
Copy Markdown
Contributor

@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.

@abe33

abe33 commented Nov 4, 2015

Copy link
Copy Markdown
Contributor

@lpommers Are you sure you tried with a version of Atom running the branch? I can't reproduce either issues:
moving-html-lines-with-fold

@abe33

abe33 commented Nov 4, 2015

Copy link
Copy Markdown
Contributor

@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.

@abe33

abe33 commented Nov 4, 2015

Copy link
Copy Markdown
Contributor

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:

moving-html-lines-with-fold-and-autoindent

✨

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

👏 Nice!

…ple-selections-2

Move lines up and down with multiple selections
@lpommers

lpommers commented Nov 5, 2015

Copy link
Copy Markdown
Author

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?

Running "check-licenses" task
Found dependencies without permissive licenses:
[email protected]
  License: (MIT AND CC-BY-3.0)
  Repository: git+https://github.com/kemitchell/spdx-expression-parse.js
The command "script/cibuild" exited with 1.

@abe33

abe33 commented Nov 5, 2015

Copy link
Copy Markdown
Contributor

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).

@winstliu

winstliu commented Nov 5, 2015

Copy link
Copy Markdown
Contributor

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.

Comment thread src/text-editor.coffee Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 "intersection" -> "intersecting"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the heads up, I pushed a fix on @lpommers repo, it'll be available when he'll merge the branch.

abe33 and others added 2 commits November 5, 2015 20:36
@abe33

abe33 commented Nov 7, 2015

Copy link
Copy Markdown
Contributor

@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.

@winstliu

winstliu commented Nov 7, 2015

Copy link
Copy Markdown
Contributor

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.

@nathansobo

Copy link
Copy Markdown
Contributor

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.

nathansobo pushed a commit that referenced this pull request Nov 7, 2015
…ltiple-selections

Move lines up and down with multiple selections
@nathansobo
nathansobo merged commit 1fd2ba0 into atom:master Nov 7, 2015
@izuzak

izuzak commented Nov 8, 2015

Copy link
Copy Markdown
Contributor

I 👏 you for the work here, @lpommers and @abe33, and also for sticking with this PR for so long.

👯

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants