Skip to content

Commit

Permalink
fix literal-scalars
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy committed Dec 14, 2024
1 parent 082c839 commit f734d6d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions scanner/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,26 @@ func (c *Context) getMultiLineState() *MultiLineState {
return c.mstate
}

func (c *Context) setLiteral(opt string) {
func (c *Context) setLiteral(lastDelimColumn int, opt string) {
mstate := &MultiLineState{
isLiteral: true,
opt: opt,
}
indent := firstLineIndentColumnByOpt(opt)
if indent > 0 {
mstate.firstLineIndentColumn = indent + 1
mstate.firstLineIndentColumn = lastDelimColumn + indent
}
c.mstate = mstate
}

func (c *Context) setFolded(opt string) {
func (c *Context) setFolded(lastDelimColumn int, opt string) {
mstate := &MultiLineState{
isFolded: true,
opt: opt,
}
indent := firstLineIndentColumnByOpt(opt)
if indent > 0 {
mstate.firstLineIndentColumn = indent + 1
mstate.firstLineIndentColumn = lastDelimColumn + indent
}
c.mstate = mstate
}
Expand Down
4 changes: 2 additions & 2 deletions scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1147,10 +1147,10 @@ func (s *Scanner) scanMultiLineHeaderOption(ctx *Context) error {
switch header {
case '|':
ctx.addToken(token.Literal("|"+opt, headerBuf, s.pos()))
ctx.setLiteral(opt)
ctx.setLiteral(s.lastDelimColumn, opt)
case '>':
ctx.addToken(token.Folded(">"+opt, headerBuf, s.pos()))
ctx.setFolded(opt)
ctx.setFolded(s.lastDelimColumn, opt)
}
if commentIndex > 0 {
comment := string(value[commentValueIndex+1:])
Expand Down
1 change: 0 additions & 1 deletion yaml_test_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ var failureTestNames = []string{
"invalid-comma-in-tag",
"invalid-tag", // pass yamlv3.
"legal-tab-after-indentation", // pass yamlv3.
"literal-scalars", // pass yamlv3.
"mapping-key-and-flow-sequence-item-anchors", // no json.
"multiline-plain-value-with-tabs-on-empty-lines", // pass yamlv3.
"multiline-scalar-at-top-level", // pass yamlv3.
Expand Down

0 comments on commit f734d6d

Please sign in to comment.