Giter Club home page Giter Club logo

Comments (4)

Dimfred avatar Dimfred commented on August 24, 2024 1

Yeah I think the second option is something they will do. If I have time I probably willl open an issue and request a unified command.

from vscode-which-key.

stevenguh avatar stevenguh commented on August 24, 2024

You will need to add the following to you shortcut (keybindings.json).

{
	"key": "p",
	"command": "whichkey.triggerKey",
	"args": {
		"key": "p",
		"when": "activeEditorIsPinned"
	},
	"when": "whichkeyVisible && activeEditorIsPinned"
}

We can also choose to bundle this as default so we don't have two separate key for pin and unpin.


Just tested this and apparently, the activeEditorIsPinned context is unset once the focus exited the editor. So which-key can't the shortcut isn't being triggered (hence, not able to pass the when condition to which-key) when the menu is in focus.

Unfortunately, this is limit of the hack we have to capture context. Either vscode keep activeEditorIsPinned set or provide a getContext API; otherwise, this is something that we can't do atm.

from vscode-which-key.

Dimfred avatar Dimfred commented on August 24, 2024

Ah that is very sad. But thank you for the investigation, hope there something will happen soon, would be great to have that.

EDIT:
So I had some time and tinkered a bit around and got a hack for that. It basically uses xdotool to send a key, and that key represents the two toggle states.

keybindings.json:

{
    "key": "f5",
    "command": "workbench.action.pinEditor",
    "when": "!activeEditorIsPinned",
},
{
    "key": "f5",
    "command": "workbench.action.unpinEditor",
    "when": "activeEditorIsPinned",
},

settings.json:

{
    "key": "p",
    "name": "Pin/Unpin editor",
    "type": "command",
    "command": "workbench.action.terminal.sendSequence",
    // without cleaning
    "args": { "text": "i;xdotool key F5\n"},
    // with cleaning
    "args": { "text": "i;xdotool key F5;xdotool key Escape;clear\n"},
},

the ;i is only to leave the normal mode of my zsh. I also bound i() { return 0 } just to not get an error in zshrc.
I would also like the command to be executed in the background without showing it in the terminal history, but not sure whether this is possible.

from vscode-which-key.

stevenguh avatar stevenguh commented on August 24, 2024

I am glad you are able to find a workaround.

I looked at the vscode api it doesn't seem like they provide anything to extension to know if the editor is pinned. To properly support this, we likely need to do a feature request to vscode for either

  • Have programmatic access to the editor pinned state
  • Add toggle command to toggle between pin and unpin

from vscode-which-key.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.