Skip to content

Commit

Permalink
fix: put indentation before tag of block sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Apr 24, 2023
1 parent 399bc7c commit 7787df8
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions emitterc.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,11 +730,6 @@ func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_e

// Expect a block item node.
func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {
if first {
if !yaml_emitter_increase_indent(emitter, false, false) {
return false
}
}
if event.typ == yaml_SEQUENCE_END_EVENT {
emitter.indent = emitter.indents[len(emitter.indents)-1]
emitter.indents = emitter.indents[:len(emitter.indents)-1]
Expand Down Expand Up @@ -910,16 +905,28 @@ func yaml_emitter_emit_scalar(emitter *yaml_emitter_t, event *yaml_event_t) bool

// Expect SEQUENCE-START.
func yaml_emitter_emit_sequence_start(emitter *yaml_emitter_t, event *yaml_event_t) bool {
if !yaml_emitter_process_anchor(emitter) {
return false
}
if !yaml_emitter_process_tag(emitter) {
return false
}
if emitter.flow_level > 0 || emitter.canonical || event.sequence_style() == yaml_FLOW_SEQUENCE_STYLE ||
yaml_emitter_check_empty_sequence(emitter) {
if !yaml_emitter_process_anchor(emitter) {
return false
}
if !yaml_emitter_process_tag(emitter) {
return false
}
emitter.state = yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE
} else {
if !yaml_emitter_increase_indent(emitter, false, false) {
return false
}
if !yaml_emitter_write_indent(emitter) {
return false
}
if !yaml_emitter_process_anchor(emitter) {
return false
}
if !yaml_emitter_process_tag(emitter) {
return false
}
emitter.state = yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE
}
return true
Expand All @@ -937,7 +944,7 @@ func yaml_emitter_emit_mapping_start(emitter *yaml_emitter_t, event *yaml_event_
}
emitter.state = yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE
} else {
// FIXME(tdakkota): should we do it for sequence/flow style?
// FIXME(tdakkota): should we do it for flow style?
//
// Write same indent as mapping have.
// In cases like this:
Expand Down

0 comments on commit 7787df8

Please sign in to comment.