Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Combine go to test file and implementation of test file commands to a single toggle command #729

Closed
mattetti opened this issue Jan 16, 2017 · 4 comments

Comments

@mattetti
Copy link
Contributor

Switching back and forth between the implementation and the test file should be able to be mapped to a keyboard shortcut. We have 2 exposed commands that can be mapped:

https://github.com/Microsoft/vscode-go/blob/fcc14da45c4228a2c8ce0aca5f7b2842eb03ef74/package.json#L139

  • go.open.test.file
  • go.open.test.implementation
{
        "key": "cmd+alt+t",
        "command": "go.open.test.file"
    }

Would work one way, but we would need to add some sort of when condition. A potentially better option would be to have a toggle command.

@ramya-rao-a what do you think?

@mattetti
Copy link
Contributor Author

It doesn't look like the when API would allow to check the current filename and turn on/off a specific command: https://code.visualstudio.com/docs/customization/keybindings#_when-clause-contexts

@ramya-rao-a
Copy link
Contributor

Toggle would be a better option, in which case I'd prefer to replace the existing 2 commands with just a single command "Go: Toggle Test File" (needs a better name?)

The when api does support the editorLangId which we can use to bind to the toggle command.

@ramya-rao-a ramya-rao-a changed the title Documentation: how to add a keyboard shortcut to switch between impl / test files Combine go to test file and implementation of test file commands to a single toggle command Jan 18, 2017
@mattetti
Copy link
Contributor Author

awesome, thanks @ramya-rao-a !

@ramya-rao-a
Copy link
Contributor

The latest update (0.6.53) has this new toggle command.

From the Changelog:

New toggle command Go: Toggle Test File that lets you toggle between your Go file and the corresponding test file. Previous commands Go: Open Test File and Go: Open Implementation For Test File have been deprecated in favor of this new command. PR 739. You can add a keyboard binding to this as below:

        {
            "key": "ctrl+shift+t",
            "command": "go.toggle.test.file",
            "when": "editorTextFocus && editorLangId == 'go'"
        }

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants