Skip to content

Commit 72d36f6

Browse files
authored
Merge branch 'main' into jsjoeio/add-troubleshooting
2 parents b238d04 + 646f243 commit 72d36f6

File tree

5 files changed

+108
-7
lines changed

5 files changed

+108
-7
lines changed

ci/steps/brew-bump.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ main() {
2323
# Find the docs for bump-formula-pr here
2424
# https://github.com/Homebrew/brew/blob/master/Library/Homebrew/dev-cmd/bump-formula-pr.rb#L18
2525
local output
26-
if ! output=$(brew bump-formula-pr --version="${VERSION}" code-server --no-browse --no-audit 2>&1); then
26+
if ! output=$(brew bump-formula-pr --version="${VERSION}" code-server --no-browse --no-audit --message="PR opened by @${GITHUB_ACTOR}" 2>&1); then
2727
if [[ $output == *"Duplicate PRs should not be opened"* ]]; then
2828
echo "$VERSION is already submitted"
2929
exit 0

patches/cli-window-open.diff

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
Make opening files/folders from the terminal only open in the current instance
2+
3+
Previously they would open in every code-server tab/window.
4+
5+
To test:
6+
7+
1. Run code-server
8+
2. Open code-server
9+
3. Open terminal
10+
4. Open another code-server window
11+
5. Run code-server with a file or directory argument
12+
13+
The file or directory should only open from the instance attached to that
14+
terminal.
15+
16+
Index: code-server/lib/vscode/src/vs/server/node/remoteTerminalChannel.ts
17+
===================================================================
18+
--- code-server.orig/lib/vscode/src/vs/server/node/remoteTerminalChannel.ts
19+
+++ code-server/lib/vscode/src/vs/server/node/remoteTerminalChannel.ts
20+
@@ -89,7 +89,7 @@ export class RemoteTerminalChannel exten
21+
uriTransformer: IURITransformer;
22+
}>();
23+
24+
- private readonly _onExecuteCommand = this._register(new Emitter<{ reqId: number; commandId: string; commandArgs: any[] }>());
25+
+ private readonly _onExecuteCommand = this._register(new Emitter<{ reqId: number; terminalId: number; commandId: string; commandArgs: any[] }>());
26+
readonly onExecuteCommand = this._onExecuteCommand.event;
27+
28+
constructor(
29+
@@ -240,20 +240,20 @@ export class RemoteTerminalChannel exten
30+
const ipcHandlePath = createRandomIPCHandle();
31+
env.VSCODE_IPC_HOOK_CLI = ipcHandlePath;
32+
const commandsExecuter: ICommandsExecuter = {
33+
- executeCommand: <T>(id: string, ...args: any[]): Promise<T> => this._executeCommand(id, args, uriTransformer)
34+
+ executeCommand: <T>(commandId: string, ...args: any[]): Promise<T> => this._executeCommand(terminalId, commandId, args, uriTransformer)
35+
};
36+
const cliServer = new CLIServerBase(commandsExecuter, this._logService, ipcHandlePath);
37+
38+
- const id = await this._ptyService.createProcess(shellLaunchConfig, initialCwd, args.cols, args.rows, args.unicodeVersion, env, baseEnv, args.options, args.shouldPersistTerminal, args.workspaceId, args.workspaceName);
39+
- this._ptyService.onProcessExit(e => e.id === id && cliServer.dispose());
40+
+ const terminalId = await this._ptyService.createProcess(shellLaunchConfig, initialCwd, args.cols, args.rows, args.unicodeVersion, env, baseEnv, args.options, args.shouldPersistTerminal, args.workspaceId, args.workspaceName);
41+
+ this._ptyService.onProcessExit(e => e.id === terminalId && cliServer.dispose());
42+
43+
return {
44+
- persistentTerminalId: id,
45+
+ persistentTerminalId: terminalId,
46+
resolvedShellLaunchConfig: shellLaunchConfig
47+
};
48+
}
49+
50+
- private _executeCommand<T>(commandId: string, commandArgs: any[], uriTransformer: IURITransformer): Promise<T> {
51+
+ private _executeCommand<T>(terminalId: number, commandId: string, commandArgs: any[], uriTransformer: IURITransformer): Promise<T> {
52+
let resolve!: (data: any) => void;
53+
let reject!: (err: any) => void;
54+
const result = new Promise<T>((_resolve, _reject) => {
55+
@@ -276,6 +276,7 @@ export class RemoteTerminalChannel exten
56+
});
57+
this._onExecuteCommand.fire({
58+
reqId,
59+
+ terminalId,
60+
commandId,
61+
commandArgs: serializedCommandArgs
62+
});
63+
Index: code-server/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts
64+
===================================================================
65+
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts
66+
+++ code-server/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts
67+
@@ -94,10 +94,14 @@ class RemoteTerminalBackend extends Base
68+
this._remoteTerminalChannel.onExecuteCommand(async e => {
69+
const reqId = e.reqId;
70+
const commandId = e.commandId;
71+
+ const terminalId = e.terminalId;
72+
if (!allowedCommands.includes(commandId)) {
73+
this._remoteTerminalChannel.sendCommandResult(reqId, true, 'Invalid remote cli command: ' + commandId);
74+
return;
75+
}
76+
+ if (typeof terminalId !== "undefined" && !this._ptys.has(terminalId)) {
77+
+ return
78+
+ }
79+
const commandArgs = e.commandArgs.map(arg => revive(arg));
80+
try {
81+
const result = await this._commandService.executeCommand(e.commandId, ...commandArgs);
82+
Index: code-server/lib/vscode/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts
83+
===================================================================
84+
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts
85+
+++ code-server/lib/vscode/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts
86+
@@ -88,8 +88,8 @@ export class RemoteTerminalChannelClient
87+
get onProcessOrphanQuestion(): Event<{ id: number }> {
88+
return this._channel.listen<{ id: number }>('$onProcessOrphanQuestion');
89+
}
90+
- get onExecuteCommand(): Event<{ reqId: number; commandId: string; commandArgs: any[] }> {
91+
- return this._channel.listen<{ reqId: number; commandId: string; commandArgs: any[] }>('$onExecuteCommand');
92+
+ get onExecuteCommand(): Event<{ reqId: number; terminalId: number; commandId: string; commandArgs: any[] }> {
93+
+ return this._channel.listen<{ reqId: number; terminalId: number; commandId: string; commandArgs: any[] }>('$onExecuteCommand');
94+
}
95+
get onDidRequestDetach(): Event<{ requestId: number; workspaceId: string; instanceId: number }> {
96+
return this._channel.listen<{ requestId: number; workspaceId: string; instanceId: number }>('$onDidRequestDetach');

patches/display-language.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html
9191
+ return cb(undefined, result)
9292
+ }
9393
+ const path = nlsConfig['vs/nls']._resolvedLanguagePackCoreLocation + "/" + bundle.replace(/\//g, "!") + ".nls.json"
94-
+ fetch(`{{WORKBENCH_WEB_BASE_URL}}/vscode-remote-resource?path=${encodeURIComponent(path)}`)
94+
+ fetch(`{{WORKBENCH_WEB_BASE_URL}}/../vscode-remote-resource?path=${encodeURIComponent(path)}`)
9595
+ .then((response) => response.json())
9696
+ .then((json) => {
9797
+ bundles[bundle] = json

patches/series

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ sourcemaps.diff
1919
disable-downloads.diff
2020
telemetry.diff
2121
display-language.diff
22+
cli-window-open.diff

src/node/wrapper.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,18 @@ export class ParentProcess extends Process {
292292
const child = this.spawn()
293293
this.child = child
294294

295-
// Log both to stdout and to the log directory.
295+
// Log child output to stdout/stderr and to the log directory.
296296
if (child.stdout) {
297-
child.stdout.pipe(this.logStdoutStream)
298-
child.stdout.pipe(process.stdout)
297+
child.stdout.on("data", (data) => {
298+
this.logStdoutStream.write(data)
299+
process.stdout.write(data)
300+
})
299301
}
300302
if (child.stderr) {
301-
child.stderr.pipe(this.logStderrStream)
302-
child.stderr.pipe(process.stderr)
303+
child.stderr.on("data", (data) => {
304+
this.logStderrStream.write(data)
305+
process.stderr.write(data)
306+
})
303307
}
304308

305309
this.logger.debug(`spawned inner process ${child.pid}`)

0 commit comments

Comments
 (0)