swiftlang / vscode-swift

Visual Studio Code Extension for Swift
https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Apache License 2.0
755 stars 54 forks source link

Make sure all callbacks in registerCommand return objects properly #1154

Open michael-weng opened 3 weeks ago

michael-weng commented 3 weeks ago

Describe the bug Found this when implementing (https://github.com/swiftlang/vscode-swift/pull/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

michael-weng commented 3 weeks ago

This will be verified by https://github.com/swiftlang/vscode-swift/pull/1144 passing.

award999 commented 3 weeks ago

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