Skip to content

Commit ab2790d

Browse files
committed
Disable background window protection by default
1 parent 9c5596e commit ab2790d

File tree

3 files changed

+20
-25
lines changed

3 files changed

+20
-25
lines changed

README.md

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ with the command return value encoded as JSON, pass `expectResponse=true`.
4040
### Python example
4141

4242
Have a look at
43-
[`command_client.py`](https://github.com/knausj85/knausj_talon/blob/master/apps/vscode/command_client.py)
44-
in the knausj talon repo.
43+
[talon-vscode-command-client](https://github.com/pokey/talon-vscode-command-client).
4544

4645
## Commands
4746
Contributes the following commands:
@@ -55,17 +54,6 @@ Contributes the following commands:
5554
## Configuration
5655
Contributes the following settings:
5756

58-
### `command-server.backgroundWindowProtection`
59-
Turn this off if you're frequently seeing an error saying "This editor is not active".
60-
61-
```json
62-
{
63-
"command-server.backgroundWindowProtection": false
64-
}
65-
```
66-
67-
Defaults to `true` (protection enabled).
68-
6957
### `command-server.allowList`
7058
Allows user to specify the allowed commands using glob syntax, eg:
7159

@@ -93,20 +81,27 @@ Defaults to `[]` (doesn't deny anything).
9381

9482
## Known issues
9583

96-
- If you see errors saying "This editor is not active", disable
97-
`command-server.backgroundWindowProtection`, as described above. VSCode
98-
seems to be a bit inconsistent with determining which window has
99-
focus. There is code in the command server that tries to prevent a
100-
background window from inadvertently executing a command, but when the
101-
focused window detection fails, it will end up preventing correct commands
102-
from running.
10384
- The server won't respond until the extension is loaded. This may be obvious,
10485
but just be aware that if you have other extensions that take a while to
10586
load, the server might not respond for a little while after you load an
10687
editor window until everything is fully loaded.
88+
- There is a very unlikely race condition. If the front VSCode is hung
89+
when you issue a command, and then you switch to another VSCode, and issue a
90+
command, then if the first instance wakes up at the exact right moment it
91+
could execute the command. There is code in the command server that tries to
92+
prevent a background window from inadvertently executing a command, but
93+
VSCode seems to be a bit inconsistent with determining which window has
94+
focus. When this focused window detection fails, it will end up [preventing
95+
correct commands from running](https://github.com/knausj85/knausj_talon/issues/466). Thus, this protection has been disabled by
96+
default, as the scenario it protects against has never been observed in practice. If you do have issues with background windows trying to execute
97+
commands, please file an issue, and we can look into another way to prevent
98+
this from occurring.
10799

108100
## Release Notes
109101

102+
### 0.5.1
103+
- Disable background window protection by default.
104+
110105
### 0.5.0
111106
- Improve robustness, and add `command-server.backgroundWindowProtection` setting
112107

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"type": "git",
99
"url": "https://github.com/pokey/command-server"
1010
},
11-
"version": "0.5.0",
11+
"version": "0.5.1",
1212
"engines": {
1313
"vscode": "^1.53.0"
1414
},
@@ -53,7 +53,7 @@
5353
},
5454
"command-server.backgroundWindowProtection": {
5555
"type": "boolean",
56-
"default": true,
56+
"default": false,
5757
"description": "Whether to enable protection against background windows executing a command"
5858
}
5959
}

src/io.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { FileHandle, readFile, stat, unlink } from "fs/promises";
2-
import { STALE_TIMEOUT_MS, VSCODE_COMMAND_TIMEOUT_MS } from "./constants";
3-
import { getRequestPath, getResponsePath } from "./paths";
1+
import { FileHandle, readFile, stat } from "fs/promises";
2+
import { VSCODE_COMMAND_TIMEOUT_MS } from "./constants";
3+
import { getRequestPath } from "./paths";
44
import { Request, Response } from "./types";
55
import { writeJSON } from "./fileUtils";
66

0 commit comments

Comments
 (0)