Skip to content

Commit 063090a

Browse files
authored
Merge pull request #1359 from microsoft/fix/breakpoint-tool-paths
fix: path display in breakpoint diagnostic tool
2 parents 528ca82 + 4aebac6 commit 063090a

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he
55
## Nightly (only)
66

77
- feat: make Deno easier to configure
8+
- fix: path display issues in breakpoint diagnostic tool ([#1343](https://github.com/microsoft/vscode-js-debug/issues/1343))
89
- fix: improve breakpoint resolution in webpack HMR ([vscode#155331](https://github.com/microsoft/vscode/issues/155331))
910
- fix: allow overriding resolution of workspaceFolder in pathMapping ([#1308](https://github.com/microsoft/vscode-js-debug/issues/1308))
1011
- fix: extraneous warnings when restarting debugging ([vscode#156432](https://github.com/microsoft/vscode/issues/156432))

src/diagnosticTool/diagnosticPaths.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { IDiagnosticDump, IDiagnosticSource } from '../adapter/diagnosics';
66
import { DebugType } from '../common/contributionUtils';
77

88
const nodeInternalMarker = '<node_internals>';
9+
const node16InternalUrl = 'node:';
910

1011
export const isNodeType = (dump: IDiagnosticDump) =>
1112
dump.config.type === DebugType.Node ||
@@ -16,11 +17,14 @@ export const isBrowserType = (dump: IDiagnosticDump) =>
1617
dump.config.type === DebugType.Chrome || dump.config.type === DebugType.Edge;
1718

1819
export const sortScore = (source: IDiagnosticSource) => {
19-
if (source.absolutePath.startsWith(nodeInternalMarker)) {
20+
if (
21+
source.absolutePath.startsWith(nodeInternalMarker) ||
22+
source.url.startsWith(node16InternalUrl)
23+
) {
2024
return 2;
2125
}
2226

23-
if (source.absolutePath.includes('node_moeules')) {
27+
if (source.absolutePath.includes('node_modules')) {
2428
return 1;
2529
}
2630

@@ -31,6 +35,10 @@ export const prettyName = (
3135
source: { absolutePath: string; url: string },
3236
dump: IDiagnosticDump,
3337
) => {
38+
if (source.url.startsWith(node16InternalUrl)) {
39+
return source.url;
40+
}
41+
3442
if (source.absolutePath.startsWith(nodeInternalMarker)) {
3543
return source.absolutePath;
3644
}
@@ -57,18 +65,17 @@ export const isAbsolutePosix = (path: string) => path.startsWith('/');
5765
export const isAbsoluteWin32 = (path: string) => /^[a-z]:/i.test(path);
5866

5967
export const relative = (fromPath: string, toPath: string) => {
60-
const parts = fromPath.split('/');
61-
for (const segment of toPath.split('/')) {
62-
if (segment === '..') {
63-
parts.pop();
64-
} else if (segment === '.') {
65-
// no-op
66-
} else {
67-
parts.push(segment);
68-
}
68+
// shift off the shared prefix of both paths
69+
const fromParts = fromPath.split('/');
70+
const toParts = toPath.split('/');
71+
while (fromParts.length && toParts[0] === fromParts[0]) {
72+
fromParts.shift();
73+
toParts.shift();
6974
}
7075

71-
return parts.join('/');
76+
// ".." for each remaining level in the fromParts
77+
const nav = fromParts.length ? new Array(fromParts.length).fill('..') : ['.'];
78+
return nav.concat(toParts).join('/');
7279
};
7380

7481
export const properRelative = (fromPath: string, toPath: string): string => {

0 commit comments

Comments
 (0)