Visual studio code snippets for Javascript inside .php files

832 views Asked by At

I've got two debug snippets, one for PHP, one for Javascript. I use the same keyboard binding:

{
  "key": "ctrl+D",
  "command": "editor.action.insertSnippet",
  "when": "editorTextFocus && editorLangId == 'php'",
  "args": {
    "langId": "php",
    "name": "Debug output for PHP"
  }
}, {
  "key": "ctrl+D",
  "command": "editor.action.insertSnippet",
  "when": "editorTextFocus && editorLangId == 'javascript'",
  "args": {
    "langId": "javascript",
    "name": "Debug output for Javascript"
  }
},

Everything is fine, when I work with a .php file with PHP code or a .js file with JS code. But if I work with the JavaScript code inside PHP, it uses PHP variant, because the file language is PHP. PHP files can include PHP, JS or HTML blocks, but, as I see, the editorLangId parameter of when don't recognize it. Is there any way to refine a condition for language, to detect a "context" language?

0

There are 0 answers