Skip to content

Commit b6355cb

Browse files
Merge pull request #553 from gjsjohnmurray/fix-552
fix #552 load server-side code snippets from isfs workspace roots
2 parents 5da9d3d + 1fd1b7e commit b6355cb

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/providers/FileSystemPovider/FileSystemProvider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
4141
}
4242

4343
public async readDirectory(uri: vscode.Uri): Promise<[string, vscode.FileType][]> {
44+
uri = redirectDotvscodeRoot(uri);
4445
const parent = await this._lookupAsDirectory(uri);
4546
const api = new AtelierAPI(uri);
4647
if (!api.active) {
@@ -129,6 +130,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
129130
}
130131

131132
public createDirectory(uri: vscode.Uri): void | Thenable<void> {
133+
uri = redirectDotvscodeRoot(uri);
132134
const basename = path.posix.basename(uri.path);
133135
const dirname = uri.with({ path: path.posix.dirname(uri.path) });
134136
return this._lookupAsDirectory(dirname).then((parent) => {
@@ -376,6 +378,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
376378
}
377379

378380
private async _lookupParentDirectory(uri: vscode.Uri): Promise<Directory> {
381+
uri = redirectDotvscodeRoot(uri);
379382
const dirname = uri.with({ path: path.posix.dirname(uri.path) });
380383
return await this._lookupAsDirectory(dirname);
381384
}

src/utils/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ export async function terminalWithDocker(): Promise<vscode.Terminal> {
355355
* Also alter query to specify `ns=%SYS&csp=1`
356356
* Also handles the alternative syntax isfs://server:namespace/
357357
* in which there is no ns queryparam
358+
* For both syntaxes the namespace folder name is uppercased
358359
*
359360
* @returns uri, altered if necessary.
360361
* @throws if `ns` queryparam is missing but required.
@@ -363,22 +364,22 @@ export function redirectDotvscodeRoot(uri: vscode.Uri): vscode.Uri {
363364
if (!schemas.includes(uri.scheme)) {
364365
return uri;
365366
}
366-
const dotMatch = uri.path.match(/^\/(\.[^/]*)\/(.*)$/);
367+
const dotMatch = uri.path.match(/^\/(\.[^/]*)(\/.*)?$/);
367368
if (dotMatch && dotMatch[1] === ".vscode") {
368369
let namespace: string;
369370
const nsMatch = `&${uri.query}&`.match(/&ns=([^&]+)&/);
370371
if (nsMatch) {
371-
namespace = nsMatch[1];
372-
const newQueryString = (("&" + uri.query).replace(`ns=${namespace}`, "ns=%SYS") + "&csp=1").slice(1);
373-
return uri.with({ path: `/_vscode/${namespace}/${dotMatch[2]}`, query: newQueryString });
372+
namespace = nsMatch[1].toUpperCase();
373+
const newQueryString = (("&" + uri.query).replace(`ns=${namespace}`, "ns=%SYS") + "&csp").slice(1);
374+
return uri.with({ path: `/_vscode/${namespace}${dotMatch[2] || ""}`, query: newQueryString });
374375
} else {
375376
const parts = uri.authority.split(":");
376377
if (parts.length === 2) {
377-
namespace = parts[1];
378+
namespace = parts[1].toUpperCase();
378379
return uri.with({
379380
authority: `${parts[0]}:%SYS`,
380-
path: `/_vscode/${namespace}/${dotMatch[2]}`,
381-
query: uri.query + "&csp=1",
381+
path: `/_vscode/${namespace}${dotMatch[2] || ""}`,
382+
query: uri.query + "&csp",
382383
});
383384
}
384385
}

0 commit comments

Comments
 (0)