diff --git a/package.json b/package.json index 02312b7..c0b417f 100755 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "type": "git", "url": "https://github.com/cursorless-dev/command-server" }, - "version": "0.11.0", + "version": "0.12.0", "engines": { "vscode": "^1.53.0" }, @@ -109,6 +109,11 @@ "type": "boolean", "default": false, "description": "Whether to enable protection against background windows executing a command" + }, + "command-server.communicationDirLocation": { + "type": "string", + "default": "", + "description": "The directory in which the command server will create a directory to communicate with the client. You shouldn't set this unless your TMPDIR/TEMP/TMP environment variables are inconsistent between VS Code and the Talon/Python command client. Currently, this is only useful when set to a temporary directory." } } } @@ -139,6 +144,6 @@ "dependencies": { "minimatch": "^3.0.4", "rimraf": "^3.0.2", - "talon-rpc": "2.1.0" + "talon-rpc": "2.2.0" } } diff --git a/src/communicationDirLocationSetting.ts b/src/communicationDirLocationSetting.ts new file mode 100644 index 0000000..735f9e8 --- /dev/null +++ b/src/communicationDirLocationSetting.ts @@ -0,0 +1,17 @@ +import * as vscode from "vscode"; + +export function getCommunicationDirLocationSetting(): string | undefined { + const value = vscode.workspace + .getConfiguration("command-server") + .get("communicationDirLocation") + ?.trim(); + return value ? value : undefined; +} + +export function onCommunicationDirLocationSettingChange(callback: () => void) { + vscode.workspace.onDidChangeConfiguration((e) => { + if (e.affectsConfiguration("command-server.communicationDirLocation")) { + callback(); + } + }); +} diff --git a/src/extension.ts b/src/extension.ts index 9f85a31..59dfe0f 100755 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,16 +1,25 @@ import { NodeIo, TalonRpcServer } from "talon-rpc"; import * as vscode from "vscode"; import CommandRunner from "./commandRunner"; +import { + getCommunicationDirLocationSetting, + onCommunicationDirLocationSettingChange, +} from "./communicationDirLocationSetting"; import { RPC_DIR_NAME } from "./constants"; import { FocusedElementType } from "./types"; export async function activate(context: vscode.ExtensionContext) { const commandRunner = new CommandRunner(); - const io = new NodeIo(RPC_DIR_NAME); - const rpc = new TalonRpcServer(io, commandRunner.runCommand); - + let io = new NodeIo(RPC_DIR_NAME, getCommunicationDirLocationSetting()); + let rpc = new TalonRpcServer(io, commandRunner.runCommand); await io.initialize(); + onCommunicationDirLocationSettingChange(async () => { + io = new NodeIo(RPC_DIR_NAME, getCommunicationDirLocationSetting()); + rpc = new TalonRpcServer(io, commandRunner.runCommand); + await io.initialize(); + }); + let focusedElementType: FocusedElementType | undefined; context.subscriptions.push( diff --git a/yarn.lock b/yarn.lock index fa60e05..4d273f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1350,10 +1350,10 @@ table@^6.0.4: slice-ansi "^4.0.0" string-width "^4.2.0" -talon-rpc@2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/talon-rpc/-/talon-rpc-2.1.0.tgz#fd66e8ace51a8d359cb960f6269dfbf11915e1e9" - integrity sha512-ADIJtafDcm2FYx1Jk0wah1fm5lxFkUT3XIvOKxiCkyckMGS5uQ1BgdacG5fnSLbJQcj5DZ9Shu0DDh8N1k1CzA== +talon-rpc@2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/talon-rpc/-/talon-rpc-2.2.0.tgz#db7f13a7b5dfac3af896801577dd430aac0cf9ef" + integrity sha512-ORMJnDjPZ0fgSn6vAwqMDIkPQosTVBRFt5J533L7bn/8yxPEZy5eqTE7pXN8324EinJq7uSjUeYlr1zIW8qNaQ== text-table@^0.2.0: version "0.2.0"