I'm developing a plugin for VSCode.
The parameters used are read from the settings.json
file and can be modified by the user on the extension settings
page.
The line of code used to read a parameter from settings.json
is:
const value = vscode.workspace.getConfiguration(configKey).get('parameterName');
When I start the plugin the parameters are read correctly, but if I change them in the extension settings
page the changes are not recognized. However, if I close the editor and restart it, the modified parameters are finally recognized and used.
Is this a normal behavior for a plugin or is there a system that I don't know about to make the plugin immediately recognize parameter changes as soon as they are set by the user?
I found the solution on my own by reading the VSCode API documentation and the code written for the extensions of many software houses.
There is no direct and clean way to intercept changes made to configuration parameters and consequently make them automatically active.
The only way to activate the new configuration parameter values is to restart VSCode or call the Reload window
command:
F1
or Ctrl+Shift+P
or Shift+Command+P
;reload window
;Developer: Reload Window
;If, however, you are developing a new extension for VSCode, remember to add a paragraph to the README.md
file in which you explain to the user the procedure I have just written.