豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 35cc9d5

Browse files
committed
fix: use 1-based line/column and fix wasm offsets in stack frames
1 parent ecef712 commit 35cc9d5

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/formatters/ConsoleFormatter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ export class ConsoleFormatter {
177177
'### Stack trace',
178178
this.#formatFragment(stackTrace.syncFragment),
179179
...stackTrace.asyncFragments.map(this.#formatAsyncFragment.bind(this)),
180+
'Note: line and column numbers use 1-based indexing',
180181
].join('\n');
181182
}
182183

@@ -198,7 +199,8 @@ export class ConsoleFormatter {
198199
#formatFrame(frame: DevTools.DevTools.StackTrace.StackTrace.Frame): string {
199200
let result = `at ${frame.name ?? '<anonymous>'}`;
200201
if (frame.uiSourceCode) {
201-
result += ` (${frame.uiSourceCode.displayName()}:${frame.line}:${frame.column})`;
202+
const location = frame.uiSourceCode.uiLocation(frame.line, frame.column);
203+
result += ` (${location.linkText(/* skipTrim */ false, /* showColumnNumber */ true)})`;
202204
} else if (frame.url) {
203205
result += ` (${frame.url}:${frame.line}:${frame.column})`;
204206
}

tests/formatters/ConsoleFormatter.test.js.snapshot

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ at foo (foo.ts:10:2)
2222
at bar (foo.ts:20:2)
2323
--- setTimeout -------------------------
2424
at schedule (util.ts:5:2)
25+
Note: line and column numbers use 1-based indexing
2526
`;
2627

2728
exports[`ConsoleFormatter > toStringDetailed > formats a console.error message 1`] = `
@@ -57,6 +58,7 @@ at foo (foo.ts:10:2)
5758
at bar (foo.ts:20:2)
5859
--- setTimeout -------------------------
5960
at schedule (util.ts:5:2)
61+
Note: line and column numbers use 1-based indexing
6062
`;
6163

6264
exports[`ConsoleFormatter > toStringDetailed > handles \"Execution context is not available\" error in args 1`] = `

tests/tools/console.test.js.snapshot

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@ Message: warn> hello world
55
### Arguments
66
Arg #0: hello world
77
### Stack trace
8-
at bar (main.js:2:10)
9-
at foo (main.js:6:2)
10-
at Iife (main.js:10:2)
11-
at <anonymous> (main.js:9:0)
8+
at bar (main.js:3:11)
9+
at foo (main.js:7:3)
10+
at Iife (main.js:11:3)
11+
at <anonymous> (main.js:10:1)
12+
Note: line and column numbers use 1-based indexing
1213
`;
1314

1415
exports[`console > get_console_message > applies source maps to stack traces of uncaught exceptions 1`] = `
1516
# test response
1617
ID: 1
1718
Message: error> Uncaught Error: b00m!
1819
### Stack trace
19-
at bar (main.js:2:8)
20-
at foo (main.js:6:2)
21-
at Iife (main.js:10:2)
22-
at <anonymous> (main.js:9:0)
20+
at bar (main.js:3:9)
21+
at foo (main.js:7:3)
22+
at Iife (main.js:11:3)
23+
at <anonymous> (main.js:10:1)
24+
Note: line and column numbers use 1-based indexing
2325
`;
2426

2527
exports[`console > get_console_message > issues type > gets issue details with node id parsing 1`] = `

0 commit comments

Comments
 (0)