26 lines
980 B
TypeScript
Raw Normal View History

2023-05-05 21:27:40 +08:00
import * as vscode from 'vscode';
import CommandManager from '../command/commandManager';
2023-05-09 10:34:33 +08:00
import { MessageHandler } from './messageHandler';
2023-05-10 17:56:56 +08:00
import { regInMessage, regOutMessage } from '../util/reg_messages';
2023-05-05 21:27:40 +08:00
2023-05-10 17:56:56 +08:00
regInMessage({command: 'regCommandList'});
regOutMessage({command: 'regCommandList', result: [{name: '', pattern: '', description: ''}]});
2023-05-16 14:35:01 +08:00
export async function regCommandList(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise<void> {
2023-05-05 21:27:40 +08:00
const commandList = CommandManager.getInstance().getCommandList();
const commandCovertedList = commandList.map(command => {
if (command.args > 0) {
// replace {{prompt}} with {{["",""]}}, count of "" is args
const prompt = Array.from({length: command.args}, () => "");
command.pattern = command.pattern.replace('{{prompt}}', '{{' + JSON.stringify(prompt) + '}}');
}
return command;
});
MessageHandler.sendMessage(panel, { command: 'regCommandList', result: commandCovertedList });
2023-05-05 21:27:40 +08:00
return;
}
2023-05-08 12:09:52 +08:00
2023-05-05 21:27:40 +08:00