Skip to content

Commit

Permalink
Merge branch 'main' into helm-priorityClassName
Browse files Browse the repository at this point in the history
  • Loading branch information
jsjoeio authored Jul 18, 2022
2 parents 467437a + 19f486b commit 9ff3bf4
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 18 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib/vscode
11 changes: 0 additions & 11 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,3 @@ trailingComma: all
arrowParens: always
singleQuote: false
useTabs: false

overrides:
# Attempt to keep VScode's existing code style intact.
- files: "lib/vscode/**/*.ts"
options:
# No limit defined upstream.
printWidth: 10000
semi: true
singleQuote: true
useTabs: true
arrowParens: avoid
2 changes: 1 addition & 1 deletion ci/steps/brew-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ main() {
# Find the docs for bump-formula-pr here
# https://github.com/Homebrew/brew/blob/master/Library/Homebrew/dev-cmd/bump-formula-pr.rb#L18
local output
if ! output=$(brew bump-formula-pr --version="${VERSION}" code-server --no-browse --no-audit 2>&1); then
if ! output=$(brew bump-formula-pr --version="${VERSION}" code-server --no-browse --no-audit --message="PR opened by @${GITHUB_ACTOR}" 2>&1); then
if [[ $output == *"Duplicate PRs should not be opened"* ]]; then
echo "$VERSION is already submitted"
exit 0
Expand Down
15 changes: 15 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
- [Version updates to Code](#version-updates-to-code)
- [Patching Code](#patching-code)
- [Build](#build)
- [Troubleshooting](#troubleshooting)
- [I see "Forbidden access" when I load code-server in the browser](#i-see-forbidden-access-when-i-load-code-server-in-the-browser)
- ["Can only have one anonymous define call per script"](#can-only-have-one-anonymous-define-call-per-script)
- [Help](#help)
- [Test](#test)
- [Unit tests](#unit-tests)
Expand Down Expand Up @@ -156,6 +159,18 @@ yarn package
> If you need your builds to support older distros, run the build commands
> inside a Docker container with all the build requirements installed.
### Troubleshooting

#### I see "Forbidden access" when I load code-server in the browser

This means your patches didn't apply correctly. We have a patch to remove the auth from vanilla Code because we use our own.

Try popping off the patches with `quilt pop -a` and reapplying with `quilt push -a`.

### "Can only have one anonymous define call per script"

Code might be trying to use a dev or prod HTML in the wrong context. You can try re-running code-server and setting `VSCODE_DEV=1`.

### Help

If you get stuck or need help, you can always start a new GitHub Discussion [here](https://github.com/coder/code-server/discussions). One of the maintainers will respond and help you out.
Expand Down
9 changes: 9 additions & 0 deletions patches/base-path.diff
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html
<link data-name="vs/workbench/workbench.web.main" rel="stylesheet" href="{{WORKBENCH_WEB_BASE_URL}}/out/vs/workbench/workbench.web.main.css">

</head>
@@ -38,7 +38,7 @@
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/loader.js"></script>
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/webPackagePaths.js"></script>
<script>
- const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location.origin).toString();
+ const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location).toString();
Object.keys(self.webPackagePaths).map(function (key, index) {
self.webPackagePaths[key] = `${baseUrl}/node_modules/${key}/${self.webPackagePaths[key]}`;
});
Index: code-server/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts
Expand Down
96 changes: 96 additions & 0 deletions patches/cli-window-open.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
Make opening files/folders from the terminal only open in the current instance

Previously they would open in every code-server tab/window.

To test:

1. Run code-server
2. Open code-server
3. Open terminal
4. Open another code-server window
5. Run code-server with a file or directory argument

The file or directory should only open from the instance attached to that
terminal.

Index: code-server/lib/vscode/src/vs/server/node/remoteTerminalChannel.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/remoteTerminalChannel.ts
+++ code-server/lib/vscode/src/vs/server/node/remoteTerminalChannel.ts
@@ -89,7 +89,7 @@ export class RemoteTerminalChannel exten
uriTransformer: IURITransformer;
}>();

- private readonly _onExecuteCommand = this._register(new Emitter<{ reqId: number; commandId: string; commandArgs: any[] }>());
+ private readonly _onExecuteCommand = this._register(new Emitter<{ reqId: number; terminalId: number; commandId: string; commandArgs: any[] }>());
readonly onExecuteCommand = this._onExecuteCommand.event;

constructor(
@@ -240,20 +240,20 @@ export class RemoteTerminalChannel exten
const ipcHandlePath = createRandomIPCHandle();
env.VSCODE_IPC_HOOK_CLI = ipcHandlePath;
const commandsExecuter: ICommandsExecuter = {
- executeCommand: <T>(id: string, ...args: any[]): Promise<T> => this._executeCommand(id, args, uriTransformer)
+ executeCommand: <T>(commandId: string, ...args: any[]): Promise<T> => this._executeCommand(terminalId, commandId, args, uriTransformer)
};
const cliServer = new CLIServerBase(commandsExecuter, this._logService, ipcHandlePath);

- const id = await this._ptyService.createProcess(shellLaunchConfig, initialCwd, args.cols, args.rows, args.unicodeVersion, env, baseEnv, args.options, args.shouldPersistTerminal, args.workspaceId, args.workspaceName);
- this._ptyService.onProcessExit(e => e.id === id && cliServer.dispose());
+ const terminalId = await this._ptyService.createProcess(shellLaunchConfig, initialCwd, args.cols, args.rows, args.unicodeVersion, env, baseEnv, args.options, args.shouldPersistTerminal, args.workspaceId, args.workspaceName);
+ this._ptyService.onProcessExit(e => e.id === terminalId && cliServer.dispose());

return {
- persistentTerminalId: id,
+ persistentTerminalId: terminalId,
resolvedShellLaunchConfig: shellLaunchConfig
};
}

- private _executeCommand<T>(commandId: string, commandArgs: any[], uriTransformer: IURITransformer): Promise<T> {
+ private _executeCommand<T>(terminalId: number, commandId: string, commandArgs: any[], uriTransformer: IURITransformer): Promise<T> {
let resolve!: (data: any) => void;
let reject!: (err: any) => void;
const result = new Promise<T>((_resolve, _reject) => {
@@ -276,6 +276,7 @@ export class RemoteTerminalChannel exten
});
this._onExecuteCommand.fire({
reqId,
+ terminalId,
commandId,
commandArgs: serializedCommandArgs
});
Index: code-server/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts
+++ code-server/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts
@@ -94,10 +94,14 @@ class RemoteTerminalBackend extends Base
this._remoteTerminalChannel.onExecuteCommand(async e => {
const reqId = e.reqId;
const commandId = e.commandId;
+ const terminalId = e.terminalId;
if (!allowedCommands.includes(commandId)) {
this._remoteTerminalChannel.sendCommandResult(reqId, true, 'Invalid remote cli command: ' + commandId);
return;
}
+ if (typeof terminalId !== "undefined" && !this._ptys.has(terminalId)) {
+ return
+ }
const commandArgs = e.commandArgs.map(arg => revive(arg));
try {
const result = await this._commandService.executeCommand(e.commandId, ...commandArgs);
Index: code-server/lib/vscode/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts
+++ code-server/lib/vscode/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts
@@ -88,8 +88,8 @@ export class RemoteTerminalChannelClient
get onProcessOrphanQuestion(): Event<{ id: number }> {
return this._channel.listen<{ id: number }>('$onProcessOrphanQuestion');
}
- get onExecuteCommand(): Event<{ reqId: number; commandId: string; commandArgs: any[] }> {
- return this._channel.listen<{ reqId: number; commandId: string; commandArgs: any[] }>('$onExecuteCommand');
+ get onExecuteCommand(): Event<{ reqId: number; terminalId: number; commandId: string; commandArgs: any[] }> {
+ return this._channel.listen<{ reqId: number; terminalId: number; commandId: string; commandArgs: any[] }>('$onExecuteCommand');
}
get onDidRequestDetach(): Event<{ requestId: number; workspaceId: string; instanceId: number }> {
return this._channel.listen<{ requestId: number; workspaceId: string; instanceId: number }>('$onDidRequestDetach');
2 changes: 1 addition & 1 deletion patches/display-language.diff
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html
+ return cb(undefined, result)
+ }
+ const path = nlsConfig['vs/nls']._resolvedLanguagePackCoreLocation + "/" + bundle.replace(/\//g, "!") + ".nls.json"
+ fetch(`{{WORKBENCH_WEB_BASE_URL}}/vscode-remote-resource?path=${encodeURIComponent(path)}`)
+ fetch(`{{WORKBENCH_WEB_BASE_URL}}/../vscode-remote-resource?path=${encodeURIComponent(path)}`)
+ .then((response) => response.json())
+ .then((json) => {
+ bundles[bundle] = json
Expand Down
1 change: 1 addition & 0 deletions patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ sourcemaps.diff
disable-downloads.diff
telemetry.diff
display-language.diff
cli-window-open.diff
14 changes: 9 additions & 5 deletions src/node/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,18 @@ export class ParentProcess extends Process {
const child = this.spawn()
this.child = child

// Log both to stdout and to the log directory.
// Log child output to stdout/stderr and to the log directory.
if (child.stdout) {
child.stdout.pipe(this.logStdoutStream)
child.stdout.pipe(process.stdout)
child.stdout.on("data", (data) => {
this.logStdoutStream.write(data)
process.stdout.write(data)
})
}
if (child.stderr) {
child.stderr.pipe(this.logStderrStream)
child.stderr.pipe(process.stderr)
child.stderr.on("data", (data) => {
this.logStderrStream.write(data)
process.stderr.write(data)
})
}

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

0 comments on commit 9ff3bf4

Please sign in to comment.