diff --git a/CHANGELOG.md b/CHANGELOG.md index b5ae1f9..7d7a1b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [0.0.6] + +- Added `custom.getExtensionInfo` to get specific information about an extension by passing the extension ID as parameter. Use `custom.listInstalledExtensions`to list all installed extensions. + ## [0.0.5] - Added `custom.workspaceFile` and `custom.workspaceFolders` to retrieve the workspace file (if any) and folders currently opened in the workspace (if any) diff --git a/README.md b/README.md index 419d3d9..d31c031 100644 --- a/README.md +++ b/README.md @@ -98,12 +98,13 @@ Some VSCode commands expect VSCode's defined types such as [Range](https://code. As the extension progresses, I plan to add more _special_ commands (i.e. commands that require some use of the [VSCode API](https://code.visualstudio.com/api/references/vscode-api)). For now, we have defined the following commands: -- `custom.goToFileLineCharacter`: allows you to nagivate to a specific position in a file by passing the file path, line and column number as arguments -- `custom.startDebugSession`: allows you to invoke `vscode.debug.startDebugging()` API by passing the workspace folder and a name or definition of a debug configuration +- `custom.goToFileLineCharacter`: allows you to navigate to a specific position in a file by passing the file path, line and column number as arguments +- `custom.startDebugSession`: allows you to invoke `vscode.debug.startDebugging()` API by passing the workspace folder and a name or definition of a debug configuration as it would be set in `launch.json` - `custom.runInTerminal`: allows you to invoke commands the currently active integrated terminal - `custom.showQuickPick`: show quick pick dialog to collect selection from the user - `custom.showInformationMessage`, `custom.showWarningMessage` and `custom.showErrorMessage`: show message dialogs to the user and let them click on a button - `custom.listInstalledExtensions`: get the list of installed extension IDs +- `custom.getExtensionInfo`: get details of an installed extension by passing the extension ID ## To implement in the near future: - Add the ability to set a breakpoint at the specified file/line combination diff --git a/package.json b/package.json index c269d8c..96a02d3 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "This extension allows you to remotely control Visual Studio Code via a REST endpoint, taking automation to the next level.", "publisher": "dpar39", "license": "MIT", - "version": "0.0.5", + "version": "0.0.6", "engines": { "vscode": "^1.55.0" }, diff --git a/src/extension.ts b/src/extension.ts index b23ece1..b5a5936 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -22,7 +22,16 @@ export function getListeningPort(): number | undefined { const SETTINGS_NAME: string = "restRemoteControl"; function setRemoteControlEnvironmentVariable(context: vscode.ExtensionContext, port: number = 0) { - context.environmentVariableCollection.replace("REMOTE_CONTROL_PORT", port ? `${port}` : ''); + const RC_PORT_ENVVAR_NAME = "REMOTE_CONTROL_PORT"; + if (port === 0) { + context.environmentVariableCollection.delete(RC_PORT_ENVVAR_NAME); + } else { + context.environmentVariableCollection.replace(RC_PORT_ENVVAR_NAME, port.toString()); + } + const terminalUpdateCommand = port === 0 ? `unset ${RC_PORT_ENVVAR_NAME}` : `export ${RC_PORT_ENVVAR_NAME}=${port}`; + vscode.window.terminals.map(terminal => { + terminal.sendText(terminalUpdateCommand); + }); } const startHttpServer = async ( diff --git a/src/services/requestProcessor.ts b/src/services/requestProcessor.ts index 8f2347c..317ee5e 100644 --- a/src/services/requestProcessor.ts +++ b/src/services/requestProcessor.ts @@ -69,6 +69,15 @@ export async function processRemoteControlRequest(requestObject: ControlRequest) return vscode.extensions.all.map((e) => e.id); } + if (command === "custom.getExtensionInfo") { + const extensionId = args[0]; + const extension = vscode.extensions.all.find((e) => e.id === extensionId); + if (!extension) { + throw new Error(`Extension with id=${extensionId} was not found`); + } + return extension; + } + if (command === "custom.workspaceFile") { return vscode.workspace.workspaceFile?.toString(); } diff --git a/src/test/workspace1/samples.http b/src/test/workspace1/samples.http index 1675392..2aee669 100644 --- a/src/test/workspace1/samples.http +++ b/src/test/workspace1/samples.http @@ -15,7 +15,19 @@ content-type: application/json { "command": "custom.listInstalledExtensions" } -### get current workspace +### get extension details +POST {{endpoint}} HTTP/1.1 +content-type: application/json + +{ "command": "custom.getExtensionInfo", "args": ["dpar39.vscode-rest-control"] } + +### get current workspace file +POST {{endpoint}} HTTP/1.1 +content-type: application/json + +{ "command": "custom.workspaceFile" } + +### get current workspace folders POST {{endpoint}} HTTP/1.1 content-type: application/json