vscode-change-case
vscode-change-case copied to clipboard
Critical bug: Incorrect state handling
V. 1.0.0:
The commands “Change Case…” remain accessible even if no text editor is active, for example, when the active tab document is a bitmap image. In this case, then the error message is
Cannot destructure property 'document' of 'editor' as it is undefined.
Possible solution:
-
Use
when
clause in “package.json“, in this clause, use the context property. In the extension code, set the value of this property totrue
offalse
usingvscode.commands.executeCommand("setContext", state)
. To figure out thestate
, find out if a text editor is active, and, optionally, if it has selected text. Also, usemenus
>commandPalette
in “package.json“, list your commands with the samewhen
clause there. -
Instead of
vscode.commands.registerCommand
, usevscode.commands.registerTextEditorCommand
. It should be enough for all commands except"extension.changeCase.commands"
. -
Use
context.subscriptions.push
for all disposable objects, first of all, for commands.
Thank you. —SA