Skip to content

Commit

Permalink
Added vscode setting for tmpDir (#40)
Browse files Browse the repository at this point in the history
Co-authored-by: Phil Cohen <[email protected]>
  • Loading branch information
AndreasArvidsson and phillco authored Jan 25, 2025
1 parent 0ea02a2 commit c3a63b2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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."
}
}
}
Expand Down Expand Up @@ -139,6 +144,6 @@
"dependencies": {
"minimatch": "^3.0.4",
"rimraf": "^3.0.2",
"talon-rpc": "2.1.0"
"talon-rpc": "2.2.0"
}
}
17 changes: 17 additions & 0 deletions src/communicationDirLocationSetting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as vscode from "vscode";

export function getCommunicationDirLocationSetting(): string | undefined {
const value = vscode.workspace
.getConfiguration("command-server")
.get<string>("communicationDirLocation")
?.trim();
return value ? value : undefined;
}

export function onCommunicationDirLocationSettingChange(callback: () => void) {
vscode.workspace.onDidChangeConfiguration((e) => {
if (e.affectsConfiguration("command-server.communicationDirLocation")) {
callback();
}
});
}
15 changes: 12 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c3a63b2

Please sign in to comment.