Skip to content

Commit

Permalink
Fix cursor position
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Dec 3, 2024
1 parent 356055b commit 3d9ed04
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,13 @@ async function nativeTraceSource(
?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')
?.replace('__webpack_exports__.', '') ||
'<unknown>',
column: originalPosition.column ?? 0,
file: originalPosition.source,
column: (originalPosition.column ?? 0) + 1,
file: originalPosition.source?.startsWith('file://')
? path.relative(
process.cwd(),
url.fileURLToPath(originalPosition.source)
)
: originalPosition.source,
lineNumber: originalPosition.line ?? 0,
// TODO: c&p from async createOriginalStackFrame but why not frame.arguments?
arguments: [],
Expand Down
5 changes: 2 additions & 3 deletions test/development/app-dir/dynamic-error-trace/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@ describe('app dir - dynamic error trace', () => {
)

const codeframe = await getRedboxSource(browser)
// TODO(NDX-115): column for "^"" marker is inconsistent between native, Webpack, and Turbopack
expect(codeframe).toEqual(
process.env.TURBOPACK
? outdent`
app/lib.js (4:12) @ Foo
app/lib.js (4:13) @ Foo
2 |
3 | export function Foo() {
> 4 | useHeaders()
| ^
| ^
5 | return 'foo'
6 | }
7 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ const isOwnerStackEnabled =
if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot(`""`)
expect(source).toMatchInlineSnapshot(`
"app/rsc/page.js (5:10) @ Inner
"app/rsc/page.js (5:11) @ Inner
3 | // Intermediate component for testing owner stack
4 | function Inner() {
> 5 | return <Foo />
| ^
| ^
6 | }
7 |
8 | export default function Page() {"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ const isOwnerStackEnabled =

if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot(
`"at Page (app/rsc/page.js (11:7))"`
`"at Page (app/rsc/page.js (11:8))"`
)
expect(source).toMatchInlineSnapshot(`
"app/rsc/page.js (5:10) @ Inner
"app/rsc/page.js (5:11) @ Inner
3 | // Intermediate component for testing owner stack
4 | function Inner() {
> 5 | return <Foo />
| ^
| ^
6 | }
7 |
8 | export default function Page() {"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ const isOwnerStackEnabled =
`"at Page (app/rsc/page.tsx (6:13))"`
)
expect(source).toMatchInlineSnapshot(`
"app/rsc/page.tsx (7:9) @ <anonymous>
"app/rsc/page.tsx (7:10) @ <anonymous>
5 | <div>
6 | {list.map((item, index) => (
> 7 | <span>{item}</span>
| ^
| ^
8 | ))}
9 | </div>
10 | )"
Expand Down

0 comments on commit 3d9ed04

Please sign in to comment.