irvnriir
irvnriir

Reputation: 806

Switch to, and from, Preview, with 1 keyboard shortcut?

I tried using textInputFocus && !inputFocus && editorLangId == 'markdown' and textInputFocus && editorReadonly && editorLangId == 'markdown' in When Expression for markdown.showSource, with relevant respective versions for markdown.showPreview .

But the shortcut still doesn't work when the Preview has Focus .

Upvotes: 0

Views: 149

Answers (1)

Mark
Mark

Reputation: 181050

If you look at the markdown.showSource in the Keybindings Shortcuts you will see it has no context/when clause. It must just find the matching resource and go to it.

Also when a preview is active, you will see that the language ID in the bottom right corner disappears, so editorLangId == markdown will presumably always fail.

If you want a when clause to prevent keybinding conflicts, try:

  {
    "key": "alt+e",
    "command": "markdown.showSource",
    "when": "markdownPreviewFocus"
  }

Learn about the Developer: Inspect Context Keys command, see inspect context keys utility. That is how I found the markdownPreviewFocus clause.

Upvotes: 1

Related Questions