diff --git a/client/src/languageserver.ts b/client/src/languageserver.ts index c81a053180779d04e7729e9b63a24450d701f648..707199626ac7a164196925a7434f904b694fcc53 100644 --- a/client/src/languageserver.ts +++ b/client/src/languageserver.ts @@ -47,10 +47,34 @@ function registerCustomCommands(context: ExtensionContext) { } } })) + + context.subscriptions.push(Commands.registerCommand('lua.exportDocument', async () => { + if (!defaultClient) { + return; + }; + let outputs = await vscode.window.showOpenDialog({ + defaultUri: vscode.Uri.joinPath( + context.extensionUri, + 'server', + 'log', + ), + openLabel: "Export documents to this folder", + canSelectFiles: false, + canSelectFolders: true, + canSelectMany: false, + }); + let output = outputs?.[0]; + if (!output) { + return; + }; + defaultClient.client.sendRequest(ExecuteCommandRequest.type, { + command: 'lua.exportDocument', + arguments: [output.toString()], + }) + })) } class LuaClient { - public client: LanguageClient; private disposables = new Array<Disposable>(); constructor(private context: ExtensionContext, diff --git a/package.json b/package.json index d9753d45b70a5b38e0aa56b744fc46fbe7f3346b..381864703c8ef4cad651e05550ec150c09adb5e8 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ { "command": "lua.psi.view", "title": "Lua Psi Viewer" + "command": "lua.exportDocument", } ], "configuration": { @@ -2913,7 +2914,7 @@ "menus": { "editor/context": [ { - "command": "lua.psi.view", + "command": "lua.exportDocument", "group": "z_commands", "when": "resourceLangId == lua" } diff --git a/package/package.lua b/package/package.lua index 166ac435f26728ceb9657a53e9610d004e93dbab..0cec6152d14ee50945b0b7b6fe12a27be50d1220 100644 --- a/package/package.lua +++ b/package/package.lua @@ -37,13 +37,17 @@ return { { command = "lua.psi.view", title = "Lua Psi Viewer" - } + }, + { + command = "lua.exportDocument", + title = "Export Document", + }, }, menus = { ["editor/context"] = { { when = "resourceLangId == lua", - command = "lua.psi.view", + command = "lua.exportDocument", group = "z_commands" } }