Skip to content

Commit 2492e1e

Browse files
match program by basename like the docs say
1 parent f967f6d commit 2492e1e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lldb/tools/lldb-dap/src-ts/commands/pick-process.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,16 @@ export async function pickProcess(
2626
processes.sort((a, b) => b.start - a.start);
2727
// Filter by program if requested
2828
if (typeof configuration?.program === "string") {
29-
processes = processes.filter(
30-
(proc) => proc.command === configuration.program,
31-
);
29+
const program = configuration.program;
30+
const programBaseName = path.basename(program);
31+
processes = processes
32+
.filter((proc) => path.basename(proc.command) === programBaseName)
33+
.sort((a, b) => {
34+
// Bring exact command matches to the top
35+
const aIsExactMatch = a.command === program ? 1 : 0;
36+
const bIsExactMatch = b.command === program ? 1 : 0;
37+
return bIsExactMatch - aIsExactMatch;
38+
});
3239
// Show a better message if all processes were filtered out
3340
if (processes.length === 0) {
3441
return [

0 commit comments

Comments
 (0)