Skip to content

Commit 8b5f09d

Browse files
committed
fix parsing with, insert between segments
1 parent f4414d3 commit 8b5f09d

File tree

1 file changed

+7
-10
lines changed
  • packages/next/src/client/components/react-dev-overlay/ui/components/code-frame

1 file changed

+7
-10
lines changed

packages/next/src/client/components/react-dev-overlay/ui/components/code-frame/parse-code-frame.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,21 @@ export function groupCodeFrameLines(formattedFrame: string) {
4646
// If the token is a new line with only line break "\n",
4747
// break here into a new line.
4848
// The line could also contain spaces, it's still considered line break if "\n" line has spaces.
49-
if (
50-
token &&
51-
typeof token.content === 'string' &&
52-
token.content.includes('\n')
53-
) {
49+
if (typeof token.content === 'string' && token.content.includes('\n')) {
5450
const segments = token.content.split('\n')
55-
for (const segment of segments) {
56-
lines.push(line)
57-
line = []
51+
for (let i = 0; i < segments.length; i++) {
52+
const segment = segments[i]
5853
if (segment) {
5954
line.push({
6055
...token,
6156
content: segment,
6257
})
6358
}
59+
if (i < segments.length - 1) {
60+
lines.push(line)
61+
line = []
62+
}
6463
}
65-
lines.push(line)
66-
line = []
6764
} else {
6865
line.push(token)
6966
}

0 commit comments

Comments
 (0)