Skip to content

Clicking on the blank (unlinked) area of a code lens line should focus and move the cursor #7749

Closed

Description

@eamodio
  • VSCode Version:
    Version 1.3.0-insider (1.3.0-insider)
    57c833a
  • OS Version:
    OS X El Capitan 10.11.5

Steps to Reproduce:

  1. Click on the non-link area of a code lens line
  2. Observe that nothing at all happens

Would really like it to at a minimum to focus the editor (if not already focused), but we really love it if it move the cursor to the previous line. I find myself VERY often clicking on that area to start typing above it and nothing happens.

Activity

  1. added
    feature-request
    on Jun 16, 2016
  2. eamodio commented on Jun 16, 2016

    @eamodio
    ContributorAuthor

    I'm assuming (maybe) that this wouldn't be a difficult change -- so if someone had the time to point me in the vague direction, I would be happy to attempt to open a PR for this. :)

  3. alexdima commented on Jun 17, 2016

    @alexdima
    Member

    Eric Amodio (@eamodio) PR welcome! :)

    It is in https://github.com/Microsoft/vscode/blob/master/src/vs/editor/browser/controller/mouseHandler.ts#L272

    I would extract the code that does the focus:

                if (browser.isIE11orEarlier) {
                    // IE does not want to focus when coming in from the browser's address bar
                    if ((<any>e.browserEvent).fromElement) {
                        e.preventDefault();
                        this.viewHelper.focusTextArea();
                    } else {
                        // TODO@Alex -> cancel this if focus is lost
                        setTimeout(() => {
                            this.viewHelper.focusTextArea();
                        });
                    }
                } else {
                    e.preventDefault();
                    this.viewHelper.focusTextArea();
                }
    

    to a closure called focus inside the method.

    Then, at https://github.com/Microsoft/vscode/blob/master/src/vs/editor/browser/controller/mouseHandler.ts#L296 you can call focus() and then e.preventDefault():

            } else if (targetIsViewZone) {
                let viewZoneData = <editorBrowser.IViewZoneData>t.detail;
                if (this.viewHelper.shouldSuppressMouseDownOnViewZone(viewZoneData.viewZoneId)) {
                    e.preventDefault();
                }
            }
    

    The reason focusing is complicated is because IE has some weirdness around redirecting focus when coming from the URL bar and doing a mouse down. And the shouldSuppressMouseDownOnViewZone already is a good indicator that the view zone does not want to handle mouse events.

  4. added 2 commits that reference this issue on Jul 14, 2016
    d85af39
    4ffafbd
  5. added a commit that references this issue on Aug 16, 2016
    ca979fc
  6. locked and limited conversation to collaborators on Nov 18, 2017
  7. added 3 commits that reference this issue on Sep 6, 2026
    5602786
    15824ff
    dd47837
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions