Skip to content

Commit 92daabc

Browse files
committed
Open folder at base URL
1 parent 068e07b commit 92daabc

1 file changed

Lines changed: 33 additions & 14 deletions

File tree

scripts/vscode.patch

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ index ff62e0a65a..21cd50eaf9 100644
6363
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
6464

6565
diff --git a/src/vs/code/browser/workbench/workbench.js b/src/vs/code/browser/workbench/workbench.js
66-
index 34f321f90d..9fc63daab2 100644
66+
index 34f321f90d..b1bd6a4ac9 100644
6767
--- a/src/vs/code/browser/workbench/workbench.js
6868
+++ b/src/vs/code/browser/workbench/workbench.js
6969
@@ -7,14 +7,19 @@
@@ -76,7 +76,7 @@ index 34f321f90d..9fc63daab2 100644
7676
- baseUrl: `${window.location.origin}/out`,
7777
+ baseUrl: `${base}/out`,
7878
+ baseScheme: window.location.protocol.replace(/:$/, ''),
79-
+ basePath: basePath + "/resources",
79+
+ basePath: basePath,
8080
+ baseAuthority: window.location.host,
8181
paths: {
8282
- 'vscode-textmate': `${window.location.origin}/node_modules/vscode-textmate/release/main`,
@@ -93,39 +93,40 @@ index 34f321f90d..9fc63daab2 100644
9393
});
9494

9595
diff --git a/src/vs/loader.js b/src/vs/loader.js
96-
index 40b6d2aa32..5b12b272fe 100644
96+
index 40b6d2aa32..f64b7e70d8 100644
9797
--- a/src/vs/loader.js
9898
+++ b/src/vs/loader.js
99-
@@ -497,6 +497,28 @@ var AMDLoader;
99+
@@ -497,6 +497,29 @@ var AMDLoader;
100100
}
101101
return this._addUrlArgsIfNecessaryToUrl(result);
102102
};
103103
+ /**
104-
+ * Transform a url to use the site base.
104+
+ * Transform a code-server:// URI, file:// URI, or plain path to use
105+
+ * the site base.
105106
+ */
106107
+ Configuration.prototype.requireWithBase = function (resource) {
107-
+ if (!this.options.baseScheme || !this.options.basePath || !this.options.baseAuthority) {
108+
+ if (typeof this.options.basePath === "undefined" || typeof this.options.baseAuthority === "undefined" || typeof this.options.baseScheme === "undefined") {
108109
+ return resource;
109110
+ }
110111
+ if (typeof resource === "string") {
111-
+ return resource.replace(
112-
+ /^(code-server|file):\/\/[^/]*/,
113-
+ `${this.options.baseScheme}://${this.options.baseAuthority}${this.options.basePath}`
114-
+ );
112+
+ const base = `${this.options.baseScheme}://${this.options.baseAuthority}${this.options.basePath}`;
113+
+ return resource.indexOf("/") !== 0
114+
+ ? resource.replace(/^(code-server|file):\/\/[^/]*/, `${base}/resources`)
115+
+ : `${base}${resource}`;
115116
+ }
116-
+ if (resource.scheme === this.options.baseScheme) {
117+
+ if (resource.scheme !== "code-server" && resource.scheme !== "file") {
117118
+ return resource;
118119
+ }
119120
+ return resource.with({
120121
+ authority: this.options.baseAuthority,
121122
+ scheme: this.options.baseScheme,
122-
+ path: `${this.options.basePath}${resource.path}`,
123+
+ path: `${this.options.basePath}/resources${resource.path}`,
123124
+ });
124125
+ };
125126
/**
126127
* Flag to indicate if current execution is as part of a build.
127128
*/
128-
@@ -1427,6 +1449,9 @@ var AMDLoader;
129+
@@ -1427,6 +1450,9 @@ var AMDLoader;
129130
result.getStats = function () {
130131
return _this.getLoaderEvents();
131132
};
@@ -585,7 +586,7 @@ index 1986fb6642..a3e4cbdb56 100644
585586

586587
const payload = await this.resolveWorkspaceInitializationPayload();
587588
diff --git a/src/vs/workbench/browser/web.simpleservices.ts b/src/vs/workbench/browser/web.simpleservices.ts
588-
index b253e573ae..cc6bb2535f 100644
589+
index b253e573ae..7a230fa3bd 100644
589590
--- a/src/vs/workbench/browser/web.simpleservices.ts
590591
+++ b/src/vs/workbench/browser/web.simpleservices.ts
591592
@@ -53,6 +53,14 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
@@ -694,6 +695,24 @@ index b253e573ae..cc6bb2535f 100644
694695

695696
//#endregion
696697

698+
@@ -888,7 +924,7 @@ export class SimpleWindowService extends Disposable implements IWindowService {
699+
for (let i = 0; i < _uris.length; i++) {
700+
const uri = _uris[i];
701+
if ('folderUri' in uri) {
702+
- const newAddress = `${document.location.origin}/?folder=${uri.folderUri.path}`;
703+
+ const newAddress = require.withBase(`/?folder=${uri.folderUri.path}`);
704+
if (openFolderInNewWindow) {
705+
window.open(newAddress);
706+
} else {
707+
@@ -896,7 +932,7 @@ export class SimpleWindowService extends Disposable implements IWindowService {
708+
}
709+
}
710+
if ('workspaceUri' in uri) {
711+
- const newAddress = `${document.location.origin}/?workspace=${uri.workspaceUri.path}`;
712+
+ const newAddress = require.withBase(`/?workspace=${uri.workspaceUri.path}`);
713+
if (openFolderInNewWindow) {
714+
window.open(newAddress);
715+
} else {
697716
diff --git a/src/vs/workbench/contrib/comments/browser/commentNode.ts b/src/vs/workbench/contrib/comments/browser/commentNode.ts
698717
index f4ac3fe8dd..3a3616b39e 100644
699718
--- a/src/vs/workbench/contrib/comments/browser/commentNode.ts

0 commit comments

Comments
 (0)