Skip to content

Commit 726be3b

Browse files
authored
Correctly set breakpoints in methods with quoted names (#1086)
1 parent 9256b65 commit 726be3b

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/debug/debugSession.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ async function getFileText(uri: vscode.Uri): Promise<string> {
4747
}
4848
}
4949

50+
/** Strip quotes from method `name` if present */
51+
function stripMethodNameQuotes(name: string): string {
52+
return name.charAt(0) == '"' && name.charAt(name.length - 1) == '"' ? name.slice(1, -1).replaceAll('""', '"') : name;
53+
}
54+
5055
/** converts a uri from VS Code to a server-side XDebug file URI with respect to source root settings */
5156
async function convertClientPathToDebugger(uri: vscode.Uri, namespace: string): Promise<string> {
5257
const { scheme, path } = uri;
@@ -313,6 +318,7 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
313318
) {
314319
// This breakpoint is in a method
315320
const currentdoc = (await getFileText(uri)).split(/\r?\n/);
321+
const methodName = stripMethodNameQuotes(currentSymbol.name);
316322
if (languageServer) {
317323
// selectionRange.start.line is the method definition line
318324
for (
@@ -329,15 +335,15 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
329335
breakpoint.condition,
330336
fileUri,
331337
line,
332-
currentSymbol.name,
338+
methodName,
333339
line - methodlinenum - 1,
334340
breakpoint.hitCondition
335341
);
336342
} else {
337343
return new xdebug.ClassLineBreakpoint(
338344
fileUri,
339345
line,
340-
currentSymbol.name,
346+
methodName,
341347
line - methodlinenum - 1,
342348
breakpoint.hitCondition
343349
);
@@ -351,15 +357,15 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
351357
breakpoint.condition,
352358
fileUri,
353359
line,
354-
currentSymbol.name,
360+
methodName,
355361
line - currentSymbol.selectionRange.start.line,
356362
breakpoint.hitCondition
357363
);
358364
} else {
359365
return new xdebug.ClassLineBreakpoint(
360366
fileUri,
361367
line,
362-
currentSymbol.name,
368+
methodName,
363369
line - currentSymbol.selectionRange.start.line,
364370
breakpoint.hitCondition
365371
);
@@ -539,7 +545,10 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
539545
// Find the DocumentSymbol for this method
540546
let currentSymbol: vscode.DocumentSymbol;
541547
for (const symbol of symbols) {
542-
if (symbol.name === stackFrame.method && symbol.detail.toLowerCase().includes("method")) {
548+
if (
549+
stripMethodNameQuotes(symbol.name) === stackFrame.method &&
550+
symbol.detail.toLowerCase().includes("method")
551+
) {
543552
currentSymbol = symbol;
544553
break;
545554
}

0 commit comments

Comments
 (0)