0

Command markdown.showSource shows the source code of a markdown preview, how to write the When condition so that markdown.showSource only triggers when the active editor is indeed a markdown preview?

Wenfang Du
  • 8,804
  • 9
  • 59
  • 90

1 Answers1

0

"when": "markdownPreviewFocus"

How did I find this? (With a markdown preview editor open)

  1. Toggle the Help/Developer Tools On, go to its console.

  2. Start the command Developer: Inspect Context Keys

I just clicked anywhere in vscode. In the developer tools console, you will get a long list of active context keys. I searched for preview and there were a few but this one looked really promising and it worked!

Wenfang Du
  • 8,804
  • 9
  • 59
  • 90
Mark
  • 143,421
  • 24
  • 428
  • 436
  • Thanks, that's a nice pro tip, I've added a reference link for that. And `markdownPreviewFocus` is also mentioned [here](https://github.com/microsoft/vscode/blob/0d584a908611a819db0167c26028419cd08830d6/extensions/markdown-language-features/package.json#L91). – Wenfang Du Aug 21 '21 at 00:32