Skip to content

Commit

Permalink
fix: set breakpoints predictably when launching with files (#1749)
Browse files Browse the repository at this point in the history
Fixes #1748
  • Loading branch information
connor4312 authored Jul 7, 2023
1 parent d7fe667 commit 736fb4e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he

## Nightly (only)

Nothing (yet)
- fix: set breakpoints predictably when launching with files ([#1748](https://github.com/microsoft/vscode-js-debug/issues/1748))

## v1.80 (June 2023)

Expand Down
4 changes: 4 additions & 0 deletions src/targets/browser/browserPathResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export class BrowserSourcePathResolver extends SourcePathResolverBase<IOptions>
return { url: utils.absolutePathToFileUrl(absolutePath), needsWildcard: false };
}

if (baseUrl && utils.isFileUrl(baseUrl)) {
return { url: utils.absolutePathToFileUrlWithDetection(absolutePath), needsWildcard: false };
}

let urlPath = utils.platformPathToUrlPath(path.relative(bestMatch[1], absolutePath));
const urlPrefix = bestMatch[0].replace(/\/$|^\//g, '');
if (urlPrefix) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
allThreadsStopped : false
description : Paused on breakpoint
reason : breakpoint
threadId : <number>
}
<anonymous> @ ${fixturesDir}/scripts/hello.js:1:1
20 changes: 20 additions & 0 deletions src/test/breakpoints/breakpointsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1390,4 +1390,24 @@ describe('breakpoints', () => {
await waitForPause(p);
p.assertLog();
});

itIntegrates('sets file uri breakpoints predictably (#1748)', async ({ r }) => {
createFileTree(testFixturesDir, {
'pages/main.html': '<script src="../scripts/hello.js"></script>',
'scripts/hello.js': 'console.log(42)',
});

const mainFile = join(testFixturesDir, 'pages/main.html');
const p = await r.launchUrl(absolutePathToFileUrlWithDetection(mainFile), {
url: undefined,
file: mainFile,
});

const source: Dap.Source = { path: join(testFixturesDir, 'scripts/hello.js') };
await p.dap.setBreakpoints({ source, breakpoints: [{ line: 1 }] });
p.load();

await waitForPause(p);
p.assertLog();
});
});

0 comments on commit 736fb4e

Please sign in to comment.