Skip to content

Commit

Permalink
remove unnecessary indent state updater
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy committed Dec 14, 2024
1 parent f734d6d commit 7597ecf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
27 changes: 8 additions & 19 deletions scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,27 +155,16 @@ func (s *Scanner) updateIndentLevel() {
}

func (s *Scanner) updateIndentState(ctx *Context) {
if s.lastDelimColumn > 0 {
if s.lastDelimColumn < s.column {
s.indentState = IndentStateUp
} else {
// If lastDelimColumn and s.column are the same,
// treat as Down state since it is the same column as delimiter.
s.indentState = IndentStateDown
}
} else {
s.indentState = s.indentStateFromIndentNumDifference()
if s.lastDelimColumn == 0 {
return
}
}

func (s *Scanner) indentStateFromIndentNumDifference() IndentState {
switch {
case s.prevLineIndentNum < s.indentNum:
return IndentStateUp
case s.prevLineIndentNum == s.indentNum:
return IndentStateEqual
default:
return IndentStateDown
if s.lastDelimColumn < s.column {
s.indentState = IndentStateUp
} else {
// If lastDelimColumn and s.column are the same,
// treat as Down state since it is the same column as delimiter.
s.indentState = IndentStateDown
}
}

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 @@ -38,7 +38,6 @@ var failureTestNames = []string{
"legal-tab-after-indentation", // 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.
"multiline-scalar-at-top-level-1-3", // pass yamlv3.
"nested-implicit-complex-keys", // no json.
"plain-dashes-in-flow-sequence",
Expand Down

0 comments on commit 7597ecf

Please sign in to comment.