-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Labels
yaml_v3_problemA bug in the underlying yaml library. These issues are vastly harder to fix.A bug in the underlying yaml library. These issues are vastly harder to fix.
Description
yamlfmt version
yamlfmt 0.20.0 (Homebrew)
Is your feature request related to a problem? Please describe.
Yes. Currently yamlfmt always normalizes the spacing before line comments according to the pad_line_comments setting.
When developers manually align comments in columns (a very common practice in configuration files, Ansible roles, Kubernetes manifests, documentation-style YAML, etc.), this alignment is completely destroyed.
Example:
# Before formatting (nicely aligned at column 50)
database_host: 127.0.0.1 # primary server
database_port: 5432 # default port
cache_enabled: true # enable caching
debug_mode: false # disabled in production# After yamlfmt – alignment is lost
database_host: 127.0.0.1 # primary server
database_port: 5432 # default port
cache_enabled: true # enable caching
debug_mode: false # disabled in productionEven setting pad_line_comments to a high value does not preserve large manual indents – the formatter still collapses them.
Describe the solution you’d like
Add a new boolean option in the basic formatter:
preserve_comment_indents: true|false # default: falseWhen true: Indentation before # in line comments is preserved exactly as in the original file.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
yaml_v3_problemA bug in the underlying yaml library. These issues are vastly harder to fix.A bug in the underlying yaml library. These issues are vastly harder to fix.