Skip to content

Commit 28485e2

Browse files
committed
Fix annotation index greater than line
1 parent 9c5922c commit 28485e2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/mdx/src/smooth-code/annotations.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,11 @@ function shiftGroups(
505505
): TokenGroup[] {
506506
const removedGroups = [] as TokenGroup[]
507507
let currentStartColumn = startColumn
508-
while (currentStartColumn < newStartColumn) {
509-
const currentTokenGroup = tokenGroups.shift()!
508+
while (
509+
currentStartColumn < newStartColumn &&
510+
tokenGroups.length > 0
511+
) {
512+
const currentTokenGroup = tokenGroups.shift()
510513
removedGroups.push(currentTokenGroup)
511514
const length = currentTokenGroup.tokens.reduce(
512515
(a, t) => a + t.content.length,

0 commit comments

Comments
 (0)