registerCommand method
Register a command (requires command to be defined on TypeScript side) This is a helper that creates a command registration on the TS side Returns true if successful
Implementation
Future<bool> registerCommand(
String command,
String handlerScript, {
int timeoutSeconds = 120,
}) async {
final result = await _adapter.sendRequest(
'executeScriptVce',
{
'script': '''
// Register command with handler
const disposable = context.vscode.commands.registerCommand(
params.command,
async (...args) => {
// Execute handler script with args
const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;
const handler = new AsyncFunction('params', 'context', 'args', params.handlerScript);
return await handler(params, context, args);
}
);
// Store disposable for cleanup (simplified)
return true;
''',
'params': {'command': command, 'handlerScript': handlerScript},
},
scriptName: 'registerCommand',
timeout: Duration(seconds: timeoutSeconds),
);
return result['success'] == true;
}