Skip to content

Ensure newline before new section when file lacks trailing newline#142

Open
bysiber wants to merge 1 commit intopyscaffold:mainfrom
bysiber:fix-add-section-missing-newline
Open

Ensure newline before new section when file lacks trailing newline#142
bysiber wants to merge 1 commit intopyscaffold:mainfrom
bysiber:fix-add-section-missing-newline

Conversation

@bysiber
Copy link

@bysiber bysiber commented Feb 21, 2026

Fixes #126.

When a config file doesn't end with a newline, add_section() appends the section header directly after the last value, producing malformed output like option2 = value2[section2].

The fix inserts a newline before the new section when the last existing block in the document doesn't end with one. Files that already have a trailing newline are unaffected.

When a config file doesn't end with a newline character, add_section()
would append the new section header directly after the last value,
producing malformed output like "option2 = value2[section2]".

Insert a newline Space block before the new section when the last
existing block doesn't end with one.

Fixes pyscaffold#126
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.

New section does not save on new line

1 participant