8000 Add indentation to flow values on new lines by shuheiktgw · Pull Request #759 · goccy/go-yaml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add indentation to flow values on new lines #759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shuheiktgw
Copy link
Collaborator

Closes #694
Add the proper indentations to flow values on new lines. Thanks for the review!

Before submitting your PR, please confirm the following.

  • Describe the purpose for which you created this PR.
  • Create test code that corresponds to the modification

@shuheiktgw shuheiktgw requested a review from Copilot June 12, 2025 06:56
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds proper indentation for flow values on new lines and verifies the behavior via extended test cases.

  • New test cases in parser_test.go validate correct handling of flow-style mappings and sequences, including inline comments.
  • Updates in ast/ast.go adjust flow-style value indentation logic for both mapping and sequence nodes.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
parser/parser_test.go Added multiple test cases to check flow-style indentation on new lines with comments.
ast/ast.go Updated indentation logic for flow-style mapping and sequence nodes for accurate formatting output.

8000
@@ -1450,16 +1450,25 @@ func (n *MappingValueNode) toString() string {
}
return fmt.Sprintf("%s%s: %s", space, n.Key.String(), value)
} else if keyIndentLevel < valueIndentLevel && !n.IsFlowStyle {
valueStr := n.Value.String()
// For flow-style values indented on the next line, we need to add the proper indentation
if m, ok := n.Value.(*MappingNode); ok && m.IsFlowStyle {
Copy link
Preview
Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic handling flow-style indentation for MappingNode and SequenceNode is almost identical. Consider refactoring this duplicated logic into a dedicated helper function to improve maintainability.

Copilot uses AI. Check for mistakes.

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.97%. Comparing base (52dacb8) to head (74d4101).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #759   +/-   ##
=======================================
  Coverage   77.97%   77.97%           
=======================================
  Files          22       22           
  Lines        8108     8108           
=======================================
  Hits         6322     6322           
  Misses       1370     1370           
  Partials      416      416           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AST nested sequence left-trimmed when calling String
2 participants
0