You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
selectLeft reduces selection instead of increasing #6928
My final guess: not a bug, just incomplete documentation.
From a UI standpoint, moveLeft() and moveRight() make sense if you picture them being in response to hitting shift-left or shift-right while a selection is active. However, that means that, if the selection is reversed, then selectLeft() will DESELECT the text one position to the left of the cursor.
If this analysis is right, I'd be happy to submit a PR to add "If the selection is reversed, then it deselects one position left of the cursor" etc. to the docs. That knowledge would have saved me a bit of time tonight.
That knowledge would have saved me a bit of time tonight.
Sorry to hear that, @bronson, and thanks for taking the time to provide this feedback. 🙇
I think you're right and your last comment explains why this happens, but I'm wondering if there still might be something to fix here in Atom -- @nathansobo@maxbrunsfeld@benogle, could you take a quick look perhaps?
I expected different behavior than the one that's currently in Atom. Here's a GIF which demonstrates this:
I double-click a word to select it, and then shift-left to select one character to the left. My expectation was that the selection would be extended to the left instead of reduced on the right. (@bronson's comment above explains why this happens.)
For example, Chrome and OSX Finder behaved as I expected in that situation:
In other words, when a selection is created -- I expect Atom to "wait" and see in which direction I start expanding, and then use that for further expanding the selection. I don't expect the selection to shrink on the initial expansion.
I think that's how moving a cursor already works with a selection -- here's what happens when I double-click a word and then just press left to move the cursor (notice that it's positioned to the left of the selection):
The main issue isn't a bug, but what @izuzak points out could sort of be considered a bug. On some other code paths we use Selection::initialScreenRange to wait to "decide" on the directionality of the selection if it's created via a double-click or triple-click. This is why double- or triple-clicking works correctly when followed by a drag. We would need to use the ::initialScreenRange in other methods on the selection in order to generalize this behavior.
The main issue isn't a bug, but what @izuzak points out could sort of be considered a bug. On some other code paths we use Selection::initialScreenRange to wait to "decide" on the directionality of the selection if it's created via a double-click or triple-click.
Just noticed that this is reported in another issue (#6485), so I'm going to close this in favor of that.
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!
Activity
bronson commentedon May 24, 2015
aha, reversed selections are legal
So selectLeft() doesn't take reversed selections into account. That's that's a bug, yeah?
bronson commentedon May 24, 2015
My final guess: not a bug, just incomplete documentation.
From a UI standpoint,
moveLeft()andmoveRight()make sense if you picture them being in response to hitting shift-left or shift-right while a selection is active. However, that means that, if the selection is reversed, then selectLeft() will DESELECT the text one position to the left of the cursor.If this analysis is right, I'd be happy to submit a PR to add "If the selection is reversed, then it deselects one position left of the cursor" etc. to the docs. That knowledge would have saved me a bit of time tonight.
izuzak commentedon May 24, 2015
Sorry to hear that, @bronson, and thanks for taking the time to provide this feedback. 🙇
I think you're right and your last comment explains why this happens, but I'm wondering if there still might be something to fix here in Atom -- @nathansobo @maxbrunsfeld @benogle, could you take a quick look perhaps?
I expected different behavior than the one that's currently in Atom. Here's a GIF which demonstrates this:
I double-click a word to select it, and then
shift-leftto select one character to the left. My expectation was that the selection would be extended to the left instead of reduced on the right. (@bronson's comment above explains why this happens.)For example, Chrome and OSX Finder behaved as I expected in that situation:
In other words, when a selection is created -- I expect Atom to "wait" and see in which direction I start expanding, and then use that for further expanding the selection. I don't expect the selection to shrink on the initial expansion.
I think that's how moving a cursor already works with a selection -- here's what happens when I double-click a word and then just press
leftto move the cursor (notice that it's positioned to the left of the selection):maxbrunsfeld commentedon May 27, 2015
Yeah this is the expected behavior. @bronson Your proposed change to the docs sounds good; I'd definitely merge such a PR.
nathansobo commentedon May 27, 2015
The main issue isn't a bug, but what @izuzak points out could sort of be considered a bug. On some other code paths we use
Selection::initialScreenRangeto wait to "decide" on the directionality of the selection if it's created via a double-click or triple-click. This is why double- or triple-clicking works correctly when followed by a drag. We would need to use the::initialScreenRangein other methods on the selection in order to generalize this behavior.izuzak commentedon Jul 30, 2015
Just noticed that this is reported in another issue (#6485), so I'm going to close this in favor of that.
lock commentedon Jan 21, 2019
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!