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

selectLeft reduces selection instead of increasing #6928

Closed

Description

@bronson

In this Chrome Devtools session, I call selectLeft() and the selection decreases in size.

The selectLeft documentation implies that this should not happen:

Selects the text one position left of the cursor.

Is this a bug in selectLeft? Is my selection inconsistent? (it was created by some complex vim-mode code). Something else?

screen shot 2015-05-24 at 12 05 48 am

Activity

  1. bronson commented on May 24, 2015

    @bronson
    Author

    aha, reversed selections are legal

    So selectLeft() doesn't take reversed selections into account. That's that's a bug, yeah?

  2. bronson commented on May 24, 2015

    @bronson
    Author

    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.

  3. izuzak commented on May 24, 2015

    @izuzak
    Contributor

    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:

    selection

    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:

    selection2

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

    selection3

  4. maxbrunsfeld commented on May 27, 2015

    @maxbrunsfeld
    Contributor

    Yeah this is the expected behavior. @bronson Your proposed change to the docs sounds good; I'd definitely merge such a PR.

  5. nathansobo commented on May 27, 2015

    @nathansobo
    Contributor

    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.

  6. izuzak commented on Jul 30, 2015

    @izuzak
    Contributor

    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.

  7. lock commented on Jan 21, 2019

    @lock

    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!

  8. locked as resolved and limited conversation to collaborators on Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions