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

Make sure all callbacks in registerCommand return objects properly #1154

Open
michael-weng opened this issue Oct 21, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@michael-weng
Copy link
Contributor

Describe the bug
Found this when implementing (#1144)
function commands.registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): vscode.Disposable
As show the callback param can return type any, and if we are not care with implicit return of arrow function expressions it's easy to miss this and as a result execute command will not be able to return the promise as expected.

example:
vscode.commands.registerCommand(COMMANDS.UseLocalDependency, item => {
if (item instanceof PackageNode) {
useLocalDependency(item.name, ctx);
}
}),

the above should return the promise returned by useLocalDependency

Expected behavior
All executeCommand of registered command properly return the right objects.

Environment

  • Impact all platforms
@michael-weng michael-weng added the bug Something isn't working label Oct 21, 2024
michael-weng added a commit to michael-weng/vscode-swift that referenced this issue Oct 21, 2024
- If the exist function return void, just return true in the end after
the function complete execution.
- Otherwise explicitly return the object.

Issue: swiftlang#1154
michael-weng added a commit to michael-weng/vscode-swift that referenced this issue Oct 21, 2024
michael-weng added a commit to michael-weng/vscode-swift that referenced this issue Oct 21, 2024
@plemarquand plemarquand changed the title Make sure all callbacks in registrerCommand return objects properly Make sure all callbacks in registerCommand return objects properly Oct 21, 2024
michael-weng added a commit to michael-weng/vscode-swift that referenced this issue Oct 22, 2024
The callback param of registerCommand returns type any, and if we are
not care with implicit return of arrow function expressions it's easy
to miss this and as a result execute command will not be able to return
the promise as expected.

Issue: swiftlang#1154
award999 pushed a commit that referenced this issue Oct 22, 2024
…#1155)

The callback param of registerCommand returns type any, and if we are
not care with implicit return of arrow function expressions it's easy
to miss this and as a result execute command will not be able to return
the promise as expected.

Issue: #1154
@michael-weng
Copy link
Contributor Author

This will be verified by #1144 passing.

@award999
Copy link
Contributor

To resister command callbacks return is propagated but the callback itself may not return anything

@award999 award999 moved this from Needs Verification to Unscreened in Swift Extension for Visual Studio Code Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Needs Verification
Development

No branches or pull requests

2 participants