Fix parsing of values on new lines by enabling empty lines in multiline values by default#22
Fix parsing of values on new lines by enabling empty lines in multiline values by default#22
Conversation
|
@bigkevmcd 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: bigkevmcd <867746+bigkevmcd@users.noreply.github.com>
emar-kar
left a comment
There was a problem hiding this comment.
Hello again. Great to see new updates. This catch is interesting, as I see python's version also enables it by default. Maybe it's also a valid moment to get back to the python version and confirm that other flags are working the same way?
| "testing": "multiline\nvalue", | ||
| "myoption": "another\nmultiline\nvalue", | ||
| "broken_option": "this value will miss", | ||
| "broken_option": "this value will miss\n\nits multiline", |
There was a problem hiding this comment.
Probably better to change to will not miss?
| delimiters: ":=", | ||
| commentPrefixes: Prefixes{"#", ";"}, | ||
| multilinePrefixes: Prefixes{"\t", " "}, | ||
| emptyLines: true, // Allow empty lines in multiline values by default |
There was a problem hiding this comment.
I guess this change should also lead to deprecation of the AllowEmptyLines, since this option will be ON by default and introduction of NoEmptyLines or something similar to bring back old behavior?
There was a problem hiding this comment.
@emar-kar Thanks for the reminder about this - I gave this task to Copilot to figure it out and then forgot about it😄
This PR fixes an issue where the configparser failed to parse values that are placed on a new line after the key, particularly when there are empty lines between the key and value.
Problem
The library was not correctly handling cases like:
Where
parser.Get("section", "option3")would return an empty string instead of "value3" when there were empty lines between the key and the multiline value.Root Cause
The parsing logic would terminate multiline value parsing when encountering empty lines, unless the
AllowEmptyLinesoption was explicitly enabled. This behavior was counter-intuitive for users who expected standard configuration file multiline value behavior.Solution
emptyLinesoption by default indefaultOptions()Impact
This change makes the library more user-friendly by allowing empty lines in multiline values by default, which aligns with common expectations for configuration file parsing. While this is technically a breaking change in behavior, it makes the library work as users intuitively expect.
All existing tests continue to pass, and the core functionality (interpolation, basic parsing, etc.) remains unchanged.
Fixes #14.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.