Skip to content

Commit 6db0dda

Browse files
committed
implement isfs://server:namespace/ as alternative to isfs://server/?ns=namespace (#450)
1 parent 67483b7 commit 6db0dda

File tree

5 files changed

+27
-21
lines changed

5 files changed

+27
-21
lines changed

src/api/index.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,16 @@ export class AtelierAPI {
100100
if (wsOrFile instanceof vscode.Uri) {
101101
if (schemas.includes(wsOrFile.scheme)) {
102102
workspaceFolderName = wsOrFile.authority;
103-
const { query } = url.parse(decodeURIComponent(wsOrFile.toString()), true);
104-
if (query) {
105-
if (query.ns && query.ns !== "") {
106-
namespace = query.ns.toString();
103+
const parts = workspaceFolderName.split(":");
104+
if (parts.length === 2 && config("intersystems.servers").has(parts[0].toLowerCase())) {
105+
workspaceFolderName = parts[0];
106+
namespace = parts[1];
107+
} else {
108+
const { query } = url.parse(wsOrFile.toString(true), true);
109+
if (query) {
110+
if (query.ns && query.ns !== "") {
111+
namespace = query.ns.toString();
112+
}
107113
}
108114
}
109115
}

src/debug/debugSession.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,19 @@ interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments {
3737
stopOnEntry?: boolean;
3838
}
3939

40-
/** converts a local path from VS Code to a server-side XDebug file URI with respect to source root settings */
41-
export async function convertClientPathToDebugger(localPath: string, namespace: string): Promise<string> {
42-
const { protocol, pathname, query } = url.parse(decodeURIComponent(localPath), true, true);
43-
let fileName = localPath;
44-
if (protocol && schemas.includes(protocol.slice(0, -1))) {
40+
/** converts a uri from VS Code to a server-side XDebug file URI with respect to source root settings */
41+
async function convertClientPathToDebugger(uri: vscode.Uri, namespace: string): Promise<string> {
42+
const { scheme, path } = uri;
43+
const { query } = url.parse(uri.toString(true), true);
44+
let fileName: string;
45+
if (scheme && schemas.includes(scheme)) {
4546
if (query.ns && query.ns !== "") {
4647
namespace = query.ns.toString();
4748
}
48-
fileName = pathname.slice(1).replace(/\//, ".");
49+
fileName = path.slice(1).replace(/\//, ".");
4950
} else {
5051
fileName = await vscode.workspace
51-
.openTextDocument(localPath)
52+
.openTextDocument(uri)
5253
.then(currentFile)
5354
.then((curFile) => {
5455
return curFile.name;
@@ -241,10 +242,9 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
241242
await this._debugTargetSet.wait(1000);
242243

243244
const filePath = args.source.path;
244-
const { protocol } = url.parse(decodeURIComponent(filePath), true, true);
245-
const uri =
246-
protocol && schemas.includes(protocol.slice(0, -1)) ? vscode.Uri.parse(filePath) : vscode.Uri.file(filePath);
247-
const fileUri = await convertClientPathToDebugger(args.source.path, this._namespace);
245+
const scheme = filePath.split(":")[0];
246+
const uri = schemas.includes(scheme) ? vscode.Uri.parse(filePath) : vscode.Uri.file(filePath);
247+
const fileUri = await convertClientPathToDebugger(uri, this._namespace);
248248
const [, fileName] = fileUri.match(/\|([^|]+)$/);
249249

250250
const currentList = await this._connection.sendBreakpointListCommand();

src/providers/DocumentContentProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid
108108

109109
public provideTextDocumentContent(uri: vscode.Uri, token: vscode.CancellationToken): vscode.ProviderResult<string> {
110110
const api = new AtelierAPI(uri);
111-
const query = url.parse(decodeURIComponent(uri.toString()), true).query;
111+
const query = url.parse(uri.toString(true), true).query;
112112
const fileName = query && query.csp ? uri.path.substring(1) : uri.path.split("/").slice(1).join(".");
113113
if (query) {
114114
if (query.ns && query.ns !== "") {

src/providers/FileSystemPovider/FileSystemProvider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
4747
return;
4848
}
4949
const sql = `CALL %Library.RoutineMgr_StudioOpenDialog(?,?,?,?,?,?,?)`;
50-
const { query } = url.parse(decodeURIComponent(uri.toString()), true);
50+
const { query } = url.parse(uri.toString(true), true);
5151
const type = query.type && query.type != "" ? query.type.toString() : "all";
5252
const csp = query.csp === "" || query.csp === "1";
5353
let filter = "";
@@ -181,7 +181,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
181181
if (uri.path.startsWith("/.")) {
182182
throw vscode.FileSystemError.NoPermissions("dot-folders not supported by server");
183183
}
184-
const { query } = url.parse(decodeURIComponent(uri.toString()), true);
184+
const { query } = url.parse(uri.toString(true), true);
185185
const csp = query.csp === "" || query.csp === "1";
186186
const fileName = csp ? uri.path : uri.path.slice(1).replace(/\//g, ".");
187187
if (fileName.startsWith(".")) {
@@ -244,7 +244,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
244244
}
245245

246246
public delete(uri: vscode.Uri, options: { recursive: boolean }): void | Thenable<void> {
247-
const { query } = url.parse(decodeURIComponent(uri.toString()), true);
247+
const { query } = url.parse(uri.toString(true), true);
248248
const csp = query.csp === "" || query.csp === "1";
249249
const fileName = csp ? uri.path : uri.path.slice(1).replace(/\//g, ".");
250250
if (fileName.startsWith(".")) {
@@ -330,7 +330,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
330330
throw vscode.FileSystemError.NoPermissions("dot-folders not supported by server");
331331
}
332332

333-
const { query } = url.parse(decodeURIComponent(uri.toString()), true);
333+
const { query } = url.parse(uri.toString(true), true);
334334
const csp = query.csp === "" || query.csp === "1";
335335
const fileName = csp ? uri.path : uri.path.slice(1).replace(/\//g, ".");
336336
const name = path.basename(uri.path);

src/utils/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function currentFile(document?: vscode.TextDocument): CurrentFile {
8181
const content = document.getText();
8282
let name = "";
8383
let ext = "";
84-
const { query } = url.parse(decodeURIComponent(uri.toString()), true);
84+
const { query } = url.parse(uri.toString(true), true);
8585
const csp = query.csp === "" || query.csp === "1";
8686
if (csp) {
8787
name = uri.path;

0 commit comments

Comments
 (0)