Skip to content
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

fmt: fix interface fields alignment #19866

Merged
merged 4 commits into from
Nov 15, 2023

Conversation

felipensp
Copy link
Member

@felipensp felipensp commented Nov 14, 2023

Fix #19540

🤖 Generated by Copilot at 603d820

This pull request refactors and improves the alignment logic for interface and struct fields in vlib/v/fmt. It extracts a common function for calculating the alignment, and applies it to both interface and struct declarations. It also adds a test file to verify the interface_field feature.

🤖 Generated by Copilot at 603d820

  • Extract alignment calculation logic into a separate function calculate_alignment that takes fields, alignment arrays, and field types array as parameters (link, link)
  • Modify interface_field function to take an additional parameter of field alignment, write spaces between field name and type, and skip writing type for anonymous structs (link)
  • Declare and initialize alignment arrays and field types array for interface fields in fmt.v (link)
  • Add condition to check and increment field alignment index in fmt.v (link)
  • Add test files interface_field_input.vv and interface_field_expected.vv to verify alignment feature for interface fields (link, link)

@felipensp felipensp marked this pull request as ready for review November 15, 2023 13:17
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

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

Excellent work.

@spytheman spytheman merged commit 83b4167 into vlang:master Nov 15, 2023
54 checks passed
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.

fmt: formatting interfaces does not pad between field name and type
2 participants