Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
ae383cfd
Commit
ae383cfd
authored
Feb 18, 2026
by
Niklas Mischkulnig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include full error message in toDisplayRedbox
parent
4f5da820
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
add-redbox-matchers.ts
test/lib/add-redbox-matchers.ts
+13
-7
No files found.
test/lib/add-redbox-matchers.ts
View file @
ae383cfd
...
@@ -91,8 +91,7 @@ export interface ErrorSnapshot {
...
@@ -91,8 +91,7 @@ export interface ErrorSnapshot {
}
}
/**
/**
* Focus source to just the header, errored line, and cursor.
* Strips surrounding context lines from the codeframe.
* Strips surrounding context lines.
*/
*/
function
focusSource
(
function
focusSource
(
source
:
string
|
null
,
source
:
string
|
null
,
...
@@ -102,6 +101,7 @@ function focusSource(
...
@@ -102,6 +101,7 @@ function focusSource(
let
focusedSource
=
''
let
focusedSource
=
''
const
sourceFrameLines
=
source
.
split
(
'
\
n'
)
const
sourceFrameLines
=
source
.
split
(
'
\
n'
)
let
encounteredCursor
=
false
for
(
let
i
=
0
;
i
<
sourceFrameLines
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
sourceFrameLines
.
length
;
i
++
)
{
const
sourceFrameLine
=
sourceFrameLines
[
i
].
trimEnd
()
const
sourceFrameLine
=
sourceFrameLines
[
i
].
trimEnd
()
if
(
sourceFrameLine
===
''
)
{
if
(
sourceFrameLine
===
''
)
{
...
@@ -109,12 +109,18 @@ function focusSource(
...
@@ -109,12 +109,18 @@ function focusSource(
}
}
if
(
sourceFrameLine
.
startsWith
(
'>'
))
{
if
(
sourceFrameLine
.
startsWith
(
'>'
))
{
if
(
!
encounteredCursor
)
{
// This is where the cursor will point
// This is where the cursor will point
// Include the cursor and nothing below since it's just surrounding code.
// Include the cursor and nothing below since it's just surrounding code.
focusedSource
+=
'
\
n'
+
sourceFrameLine
focusedSource
+=
'
\
n'
+
sourceFrameLine
focusedSource
+=
'
\
n'
+
sourceFrameLines
[
i
+
1
]
focusedSource
+=
'
\
n'
+
sourceFrameLines
[
i
+
1
]
break
i
++
// skip the next line since we already included it as context for the errored line
encounteredCursor
=
true
}
}
continue
}
// Include error message before or after the code frame
const
isCodeFrameLine
=
/^
{2}\s
*
\d
+
\|
/
.
test
(
sourceFrameLine
)
const
isCodeFrameLine
=
/^
{2}\s
*
\d
+
\|
/
.
test
(
sourceFrameLine
)
if
(
!
isCodeFrameLine
)
{
if
(
!
isCodeFrameLine
)
{
focusedSource
+=
'
\
n'
+
sourceFrameLine
focusedSource
+=
'
\
n'
+
sourceFrameLine
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment