Skip to content

Commit aafb74e

Browse files
committed
fix panic when a blockstring has only 1 line and blank
1 parent 63adf01 commit aafb74e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

language/lexer/lexer.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,10 @@ func blockStringValue(in string) string {
427427

428428
// Remove leading blank lines.
429429
for {
430-
if len(lines) == 1 {
430+
if isBlank := lineIsBlank(lines[0]); !isBlank {
431431
break
432432
}
433-
if isBlank := lineIsBlank(lines[0]); !isBlank {
433+
if len(lines) == 1 {
434434
break
435435
}
436436
lines = lines[1:]
@@ -442,6 +442,9 @@ func blockStringValue(in string) string {
442442
if isBlank := lineIsBlank(lines[i]); !isBlank {
443443
break
444444
}
445+
if len(lines) == 1 {
446+
break
447+
}
445448
lines = append(lines[:i], lines[i+1:]...)
446449
}
447450

0 commit comments

Comments
 (0)