Skip to content

Commit c1d2378

Browse files
committed
small fixes for debugging
1 parent 0e2bf42 commit c1d2378

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Diff for: src/debug/debugSession.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export async function convertClientPathToDebugger(localPath: string, namespace:
4545
if (query.ns && query.ns !== "") {
4646
namespace = query.ns.toString();
4747
}
48-
fileName = pathname.slice(1);
48+
fileName = pathname.slice(1).replace(/\//, ".");
4949
} else {
5050
fileName = await vscode.workspace
5151
.openTextDocument(localPath)
@@ -55,6 +55,8 @@ export async function convertClientPathToDebugger(localPath: string, namespace:
5555
});
5656
}
5757

58+
namespace = encodeURIComponent(namespace);
59+
fileName = encodeURIComponent(fileName);
5860
return `dbgp://|${namespace}|${fileName}`;
5961
}
6062

@@ -204,6 +206,7 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
204206
await this._debugTargetSet.wait(1000);
205207

206208
const filePath = args.source.path;
209+
const uri = filePath.startsWith(FILESYSTEM_SCHEMA) ? vscode.Uri.parse(filePath) : vscode.Uri.file(filePath);
207210
const fileUri = await convertClientPathToDebugger(args.source.path, this._namespace);
208211
const [, fileName] = fileUri.match(/\|([^|]+)$/);
209212

@@ -225,9 +228,9 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
225228
const line = breakpoint.line;
226229
if (breakpoint.condition) {
227230
return new xdebug.ConditionalBreakpoint(breakpoint.condition, fileUri, line);
228-
} else if (filePath.endsWith("cls")) {
229-
return await vscode.workspace.openTextDocument(filePath).then(document => {
230-
const methodMatchPattern = new RegExp(`^(?:Class)?Method (.+)(?=[( ])`, "i");
231+
} else if (fileName.endsWith("cls")) {
232+
return await vscode.workspace.openTextDocument(uri).then(document => {
233+
const methodMatchPattern = new RegExp(`^(?:Class)?Method ([^(]+)(?=[( ])`, "i");
231234
for (let i = line; line > 0; i--) {
232235
const lineOfCode = document.lineAt(i).text;
233236
const methodMatch = lineOfCode.match(methodMatchPattern);
@@ -286,7 +289,8 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
286289
stack.stack.map(
287290
async (stackFrame: xdebug.StackFrame, index): Promise<StackFrame> => {
288291
const [, namespace, name] = decodeURI(stackFrame.fileUri).match(/^dbgp:\/\/\|([^|]+)\|(.*)$/);
289-
const routine = name.includes(".") ? name : name + ".int";
292+
const routine = name;
293+
// const routine = name.includes(".") ? name : name + ".int";
290294
const fileUri = DocumentContentProvider.getUri(routine, null, namespace).toString();
291295
const source = new Source(routine, fileUri);
292296
let line = stackFrame.line + 1;

Diff for: src/providers/DocumentContentProvider.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid
2929
if (found) {
3030
return vscode.Uri.file(found);
3131
}
32+
const fileExt = name.split(".").pop();
3233
const fileName = name
3334
.split(".")
3435
.slice(0, -1)
35-
.join("/");
36-
const fileExt = name.split(".").pop();
36+
.join(fileExt.match(/cls/i) ? "/" : ".");
3737
name = fileName + "." + fileExt;
3838
let uri = vscode.Uri.file(name).with({
3939
scheme: vfs ? FILESYSTEM_SCHEMA : OBJECTSCRIPT_FILE_SCHEMA,

0 commit comments

Comments
 (0)