Skip to content

Commit c3a63b2

Browse files
Added vscode setting for tmpDir (#40)
Co-authored-by: Phil Cohen <[email protected]>
1 parent 0ea02a2 commit c3a63b2

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"type": "git",
99
"url": "https://github.com/cursorless-dev/command-server"
1010
},
11-
"version": "0.11.0",
11+
"version": "0.12.0",
1212
"engines": {
1313
"vscode": "^1.53.0"
1414
},
@@ -109,6 +109,11 @@
109109
"type": "boolean",
110110
"default": false,
111111
"description": "Whether to enable protection against background windows executing a command"
112+
},
113+
"command-server.communicationDirLocation": {
114+
"type": "string",
115+
"default": "",
116+
"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."
112117
}
113118
}
114119
}
@@ -139,6 +144,6 @@
139144
"dependencies": {
140145
"minimatch": "^3.0.4",
141146
"rimraf": "^3.0.2",
142-
"talon-rpc": "2.1.0"
147+
"talon-rpc": "2.2.0"
143148
}
144149
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as vscode from "vscode";
2+
3+
export function getCommunicationDirLocationSetting(): string | undefined {
4+
const value = vscode.workspace
5+
.getConfiguration("command-server")
6+
.get<string>("communicationDirLocation")
7+
?.trim();
8+
return value ? value : undefined;
9+
}
10+
11+
export function onCommunicationDirLocationSettingChange(callback: () => void) {
12+
vscode.workspace.onDidChangeConfiguration((e) => {
13+
if (e.affectsConfiguration("command-server.communicationDirLocation")) {
14+
callback();
15+
}
16+
});
17+
}

src/extension.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
import { NodeIo, TalonRpcServer } from "talon-rpc";
22
import * as vscode from "vscode";
33
import CommandRunner from "./commandRunner";
4+
import {
5+
getCommunicationDirLocationSetting,
6+
onCommunicationDirLocationSettingChange,
7+
} from "./communicationDirLocationSetting";
48
import { RPC_DIR_NAME } from "./constants";
59
import { FocusedElementType } from "./types";
610

711
export async function activate(context: vscode.ExtensionContext) {
812
const commandRunner = new CommandRunner();
9-
const io = new NodeIo(RPC_DIR_NAME);
10-
const rpc = new TalonRpcServer(io, commandRunner.runCommand);
11-
13+
let io = new NodeIo(RPC_DIR_NAME, getCommunicationDirLocationSetting());
14+
let rpc = new TalonRpcServer(io, commandRunner.runCommand);
1215
await io.initialize();
1316

17+
onCommunicationDirLocationSettingChange(async () => {
18+
io = new NodeIo(RPC_DIR_NAME, getCommunicationDirLocationSetting());
19+
rpc = new TalonRpcServer(io, commandRunner.runCommand);
20+
await io.initialize();
21+
});
22+
1423
let focusedElementType: FocusedElementType | undefined;
1524

1625
context.subscriptions.push(

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,10 +1350,10 @@ table@^6.0.4:
13501350
slice-ansi "^4.0.0"
13511351
string-width "^4.2.0"
13521352

1353-
talon-rpc@2.1.0:
1354-
version "2.1.0"
1355-
resolved "https://registry.yarnpkg.com/talon-rpc/-/talon-rpc-2.1.0.tgz#fd66e8ace51a8d359cb960f6269dfbf11915e1e9"
1356-
integrity sha512-ADIJtafDcm2FYx1Jk0wah1fm5lxFkUT3XIvOKxiCkyckMGS5uQ1BgdacG5fnSLbJQcj5DZ9Shu0DDh8N1k1CzA==
1353+
talon-rpc@2.2.0:
1354+
version "2.2.0"
1355+
resolved "https://registry.yarnpkg.com/talon-rpc/-/talon-rpc-2.2.0.tgz#db7f13a7b5dfac3af896801577dd430aac0cf9ef"
1356+
integrity sha512-ORMJnDjPZ0fgSn6vAwqMDIkPQosTVBRFt5J533L7bn/8yxPEZy5eqTE7pXN8324EinJq7uSjUeYlr1zIW8qNaQ==
13571357

13581358
text-table@^0.2.0:
13591359
version "0.2.0"

0 commit comments

Comments
 (0)