Last active
January 24, 2020 07:09
-
-
Save sketchbuch/777dfab2193da8cc74400872eedc8f1e to your computer and use it in GitHub Desktop.
VSC - How to detect a change of the langauge used by the active editor in a VSC Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Called when active editor language is changed: | |
// After the active editor language changes the content is "re-opened" so just listen for the open event | |
// And check the lang of the active editor | |
vscode.workspace.onDidOpenTextDocument(() => { | |
const editor = vscode.window.activeTextEditor | |
if (editor !== undefined) { | |
const { | |
document: { languageId }, | |
} = editor; | |
if (languageId.indexOf('javascript') === 0) { | |
// Do something... | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment