@@ -3,16 +3,23 @@ import { commandRunner } from "../../commandRunner";
33import { CommandFunction , CommandManager } from "../../packages/commands" ;
44
55/**
6- * Intializes a command manager for VSCode, wrapping the commandRunner
6+ * Create a command manager for VSCode, wrapping the commandRunner
77 * and vscode.executeCommand.
88 */
9- export function initializeVSCodeCommandManager <
9+ export function createVSCodeCommandManager <
1010 Commands extends Record < string , CommandFunction > ,
1111> ( ) : CommandManager < Commands > {
12- return new CommandManager ( commandRunner , wrappedExecuteCommand ) ;
12+ return new CommandManager ( commandRunner , wrapExecuteCommand ) ;
1313}
1414
15- async function wrappedExecuteCommand <
15+ /**
16+ * wrapExecuteCommand wraps commands.executeCommand to satisfy that the
17+ * type is a Promise. Type script does not seem to be smart enough
18+ * to figure out that `ReturnType<Commands[CommandName]>` is actually
19+ * a Promise, so we need to add a second layer of wrapping and unwrapping
20+ * (The `Promise<Awaited<` part) to get the right types.
21+ */
22+ async function wrapExecuteCommand <
1623 Commands extends Record < string , CommandFunction > ,
1724 CommandName extends keyof Commands & string = keyof Commands & string ,
1825> (
0 commit comments