You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you register a command with registerTextEditorCommand, then when later calling that command with commands.executeCommand(), executeCommand won't wait for that command to complete before resolving. With commands registered with registerCommand, it behaves as expected.
For example, this works:
vscode.commands.registerCommand('extension.normalCommand',()=>{returnnewPromise(resolve=>{// Do some work ...console.log("Command is now finished");resolve(123);})})// Later...vscode.commands.executeCommand('extension.normalCommand').then(value=>{console.log("Command should have already finished");console.log(value);})
Output:
Command is now finished
Command should have already finished
123
This doesn't:
vscode.commands.registerTextEditorCommand('extension.editorCommand',(editor)=>{returnnewPromise(resolve=>{// Do some work ...console.log("Command is now finished");resolve(123);})})// Later...vscode.commands.executeCommand('extension.editorCommand').then(value=>{console.log("Command should have already finished");console.log(value);})
Output:
Command should have already finished
undefined
Command is now finished
Can also create an example repo if necessary.
The text was updated successfully, but these errors were encountered:
In my callback I have a call to vscode.window.showInputBox but the code after that uses the value from the input, but the callback is finished before it can use it.
Shouldn't registerTextEditorCommand returns a T | Thenable<T> just like its big brother registerCommand, or am I doing something wrong?
If you register a command with
registerTextEditorCommand
, then when later calling that command withcommands.executeCommand()
, executeCommand won't wait for that command to complete before resolving. With commands registered withregisterCommand
, it behaves as expected.For example, this works:
Output:
This doesn't:
Output:
Can also create an example repo if necessary.
The text was updated successfully, but these errors were encountered: