Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical bug: Incorrect state handling #49

Open
SAKryukov opened this issue Nov 28, 2023 · 0 comments
Open

Critical bug: Incorrect state handling #49

SAKryukov opened this issue Nov 28, 2023 · 0 comments

Comments

@SAKryukov
Copy link

SAKryukov commented Nov 28, 2023

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 to true of false using vscode.commands.executeCommand("setContext", state). To figure out the state, find out if a text editor is active, and, optionally, if it has selected text. Also, use menus > commandPalette in “package.json“, list your commands with the same when clause there.

  • Instead of vscode.commands.registerCommand, use vscode.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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant