macisamuele / language-formatters-pre-commit-hooks

Collection of custom pre-commit hooks.
Apache License 2.0
117 stars 57 forks source link

preserve comments for toml #121

Closed ksdaftari closed 1 year ago

ksdaftari commented 1 year ago

I am noticing that for when run pretty-format-toml for toml with contents like below

# full config list in https://docs.streamlit.io/library/advanced-features/configuration
# can see current config via command "streamlit config show"

[runner]
# disabling streamlit magics 
# (See https://docs.streamlit.io/library/api-reference/write-magic/magic)
# prefer to call streamlit commands explicitly
magicEnabled = false

[browser]
# disabling sending usage stats to Streamlit
gatherUsageStats = false

will correct to

# full config list in https://docs.streamlit.io/library/advanced-features/configuration
# can see current config via command "streamlit config show"

[browser]
gatherUsageStats = false

[runner]
magicEnabled = false

removing comments from before, assuming this is not expected behavior (i have other files with comments that not having this issue)

macisamuele commented 1 year ago

I'm about to release v2.6.0 of the library that would address the concern. The fix has been introduced by updating the underlying formatting library in #134 / #137

Tested it locally and comments are preserved.