Disable peek in Visual Studio Code

Timmmm

Is there a way to disable the ctrl-click 'peek' feature in Visual Studio Code? Ideally I'd like ctrl-click to just open the file containing the definition in a new tab.

Edit: I submitted an issue to at least make it less confusing. Apparently my terminology is slightly wrong.

To clarify, there are two actions:

  1. Right-click -> Peek Definition
  2. Right-click -> Go to Definition (bound to ctrl-click)

Their behaviour is as follows:

  1. PD, Single Definition
    • Opens inline interface showing definition.
  2. PD, Multiple Definitions

    • Opens inline interface showing definitions.
  3. GtD, Single Definition

    • Open the file containing the definition.
  4. GtD, Multiple Definitions
    • Pick one of the definitions at random, open that file, and an inline interface showing all the definitions.

All of those are fine except the last. Doing both things results in a really redundant and confusing UI like this:

Confusing!

There should be a way to have one of these behaviours:

  • Pick one of the definitions at random, open that file.

Or:

  • Open inline interface showing all the definitions (in the current file)
Derek Ziemba

I've made a pull request to fix this https://github.com/Microsoft/vscode/pull/68023, but until then here's a temp fix that patches the VSCode installation files. You'll need to re-apply every update.

EDIT: The fix was merged into vscode. It should be in later versions.

With this fix Ctrl+Click will:

  • Use peek if there are multiple definitions
  • When using peek, will not navigate to the best match in the editor and cause you to lose your spot
  • If there is only one definition, it will navigate to the best match and NOT open peek.

  1. Figure out what the function that needs to be patched looks like. The method is DefinitionAction.prototype._onResult(editorService, editor, model)

  2. Go to the VSCode installation directory. %LocalAppData%\Programs\Microsoft VS Code and right click and open the directory in VSCode so that we can use VSCode's search feature to search for text in every file.

  3. Search for _onResult and evaluate every result, checking to see if the signature and body matches what we are expecting from the function we saw in step 1.

    • We know from step 1, the function _openReference is nearby. Use that to narrow the search.
    • I found it in workbench.main.js line 2454. Use bracket matching to find the end or know that it ends immediately before t.prototype._openReference
    • The function when formatted is the following (async func is compiled down to statemachine, that's why it looks nothing like the source typescript):

      t.prototype._onResult = function (e, t, r) {
        return i(this, void 0, void 0, function () {
          var i, s, a;
          return n(this, function (n) {
            switch (n.label) {
              case 0:
                return i = r.getAriaMessage(), o.alert(i), this._configuration.openInPeek ? (this._openInPeek(e, t, r), [3, 3]) : [3, 1];
              case 1:
                return s = r.nearestReference(t.getModel().uri, t.getPosition()), [4, this._openReference(t, e, s, this._configuration.openToSide)];
              case 2:
                (a = n.sent()) && r.references.length > 1 ? this._openInPeek(e, a, r) : r.dispose(), n.label = 3;
              case 3:
              return [2]
            }
          })
        })
      }
      
  4. Replace the function with the following (if using same version) or format and edit the function you found to be similar to this example. Note the o variable is the global\window object and subject to change.

    t.prototype._onResult = function (e, t, r) {
      return i(this, void 0, void 0, function () {
        return n(this, function (n) {
          switch (n.label) {
            case 0:
              return r.getAriaMessage(), o.alert(r.getAriaMessage()), this._configuration.openInPeek || r.references.length > 1 ? (this._openInPeek(e, t, r), [3, 3]) : [3, 1];
            case 1:
              return [4, this._openReference(t, e, r.nearestReference(t.getModel().uri, t.getPosition()), this._configuration.openToSide)];
            case 2:
              r.dispose(), n.label = 3;
            case 3:
            return [2]
          }
        })
      })
    }
    
  5. Launch VSCode. You will get a Your Code installation appears to be corrupt. Please reinstall. Just hit the gear icon and click Don't Show Again.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

visual studio code disable auto wrap long line

From Java

Disable tooltip hint in Visual Studio Code

From Java

Disable Visual Studio code formatting in Razor

From Java

Can you turn off Peek Definition in Visual Studio 2013 and up?

From Java

How do I disable Visual Studio Code auto save

From Java

How can I disable live code analysis in Visual Studio 2017?

From Dev

Visual Studio 2013 - Change background color of Peek Definition Window

From Dev

Is the "Peek Definition" feature available in Visual Studio 2013 Express?

From Dev

Disable git in Visual Studio 2013

From Dev

Visual studio 2013 pro peek definition hangs

From Dev

Visual studio 2013 peek not dismissing with the Escape key

From Dev

How can I disable GPU rendering in Visual Studio Code

From Dev

Visual Studio Permanently Disable Overwrite

From Dev

Disable bitcode with Visual Studio

From Dev

How to disable PHP validation in Visual Studio Code?

From Dev

Unable to disable extensions in Visual Studio

From Dev

Visual Studio 2015 C++ Create Definition without peek

From Dev

Disable IntelliSense in Visual Studio 2015

From Dev

How do I disable tabs in Visual Studio Code?

From Dev

Disable VS Code Output Window (not Visual Studio)

From Dev

Visual Studio Code Java: Disable serialVersionUID warning

From Dev

visual studio code disable auto wrap long line

From Dev

Visual studio 2013 peek not dismissing with the Escape key

From Dev

How to disable PSScriptAnalyzer's PSAvoidUsingCmdletAliases in PowerShell Extension in Visual Studio Code

From Dev

Visual Studio Code disable sidebar code slider thing

From Dev

Disable bitcode with Visual Studio

From Dev

Visual Studio 2015 Peek Definition Icon not shown

From Dev

Disable auto wrap long line in Visual Studio Code

From Dev

Disable git hook in visual studio

Related Related

  1. 1

    visual studio code disable auto wrap long line

  2. 2

    Disable tooltip hint in Visual Studio Code

  3. 3

    Disable Visual Studio code formatting in Razor

  4. 4

    Can you turn off Peek Definition in Visual Studio 2013 and up?

  5. 5

    How do I disable Visual Studio Code auto save

  6. 6

    How can I disable live code analysis in Visual Studio 2017?

  7. 7

    Visual Studio 2013 - Change background color of Peek Definition Window

  8. 8

    Is the "Peek Definition" feature available in Visual Studio 2013 Express?

  9. 9

    Disable git in Visual Studio 2013

  10. 10

    Visual studio 2013 pro peek definition hangs

  11. 11

    Visual studio 2013 peek not dismissing with the Escape key

  12. 12

    How can I disable GPU rendering in Visual Studio Code

  13. 13

    Visual Studio Permanently Disable Overwrite

  14. 14

    Disable bitcode with Visual Studio

  15. 15

    How to disable PHP validation in Visual Studio Code?

  16. 16

    Unable to disable extensions in Visual Studio

  17. 17

    Visual Studio 2015 C++ Create Definition without peek

  18. 18

    Disable IntelliSense in Visual Studio 2015

  19. 19

    How do I disable tabs in Visual Studio Code?

  20. 20

    Disable VS Code Output Window (not Visual Studio)

  21. 21

    Visual Studio Code Java: Disable serialVersionUID warning

  22. 22

    visual studio code disable auto wrap long line

  23. 23

    Visual studio 2013 peek not dismissing with the Escape key

  24. 24

    How to disable PSScriptAnalyzer's PSAvoidUsingCmdletAliases in PowerShell Extension in Visual Studio Code

  25. 25

    Visual Studio Code disable sidebar code slider thing

  26. 26

    Disable bitcode with Visual Studio

  27. 27

    Visual Studio 2015 Peek Definition Icon not shown

  28. 28

    Disable auto wrap long line in Visual Studio Code

  29. 29

    Disable git hook in visual studio

HotTag

Archive