1
1
Fork
You've already forked ecformat
0

EditorConfig: Support insert_final_newline #40

Manually merged
BaumiCoder merged 15 commits from feature/6-insert_final_newline into main 2026年05月07日 11:04:39 +02:00

Resolves #6

User perspective

Include the insert_final_newline property into the check and fix command.

It is handled after the trim_trailing_whitespace property to avoid two final newlines in the last line only contains whitespace characters. This would occur because a line with only whitespace characters does not fulfill the required for a final newline (see also message for commit 374c38a5a6).

Developer perspective

While adding the support for this further EditorConfig property some refactoring needs occurs to reduce code duplication. Beside these refactoring commits also the outdated tests/resources/README.md was adjusted in this Pull Request.

Resolves #6 ### User perspective Include the `insert_final_newline` property into the `check` and `fix` command. It is handled after the `trim_trailing_whitespace` property to avoid two final newlines in the last line only contains whitespace characters. This would occur because a line with only whitespace characters does not fulfill the required for a final newline (see also message for commit 374c38a5a6b70f259c8add4d4bab47100137a00e). ### Developer perspective While adding the support for this further EditorConfig property some refactoring needs occurs to reduce code duplication. Beside these refactoring commits also the outdated `tests/resources/README.md` was adjusted in this Pull Request.
Found in the context of the similar messages in add_final_newline.rs
If trailing whitespace is allowed the question may arise,
how the affect the handling of insert_final_newline.
Following the specification something like a row of only spaces does
not count as the final newline (as the newline is not at the file end).
I also tested some editors for their behavior. The only outlier I found
is VSCodium / VSCode, which seems to be a bug there:
https://github.com/editorconfig/editorconfig-vscode/issues/485 
Helper function to get list of expected error file names.
General description about the files and reference to the respective
source code parts to avoid incomplete or outdated information.
Documentation: State clear order of properties
All checks were successful
/ changes (pull_request) Successful in 52s
/ lint_reuse (pull_request) Successful in 1m10s
/ lint_codespell (pull_request) Successful in 1m3s
/ lint_ecformat (pull_request) Successful in 9m15s
/ test (pull_request) Successful in 57s
/ lint_cargo_deny (advisories) (pull_request) Has been skipped
/ lint_cargo_deny (bans licenses sources) (pull_request) Has been skipped
/ lint_clippy (pull_request) Has been skipped
/ lint_rustfmt (pull_request) Has been skipped
/ lint_taplo (pull_request) Has been skipped
/ lint_yamllint (pull_request) Has been skipped
/ lint_cargo_udeps (pull_request) Has been skipped
/ lint_docs_rs (pull_request) Has been skipped
a8172296e2
The properties are documented as they are processed.
This can make a difference in some edge cases,
such as if the final newline is mising
but the last line only considers out of spaces.
Fix text in test resource file
All checks were successful
/ changes (pull_request) Successful in 50s
/ lint_reuse (pull_request) Successful in 1m11s
/ lint_codespell (pull_request) Successful in 1m5s
/ lint_ecformat (pull_request) Successful in 1m55s
/ test (pull_request) Successful in 57s
/ lint_cargo_deny (advisories) (pull_request) Has been skipped
/ lint_cargo_deny (bans licenses sources) (pull_request) Has been skipped
/ lint_clippy (pull_request) Has been skipped
/ lint_rustfmt (pull_request) Has been skipped
/ lint_taplo (pull_request) Has been skipped
/ lint_yamllint (pull_request) Has been skipped
/ lint_cargo_udeps (pull_request) Has been skipped
/ lint_docs_rs (pull_request) Has been skipped
b5af43b731
BaumiCoder manually merged commit c46ba8b80b into main 2026年05月07日 11:04:39 +02:00
Sign in to join this conversation.
No reviewers
Labels
Clear labels
Compat/Breaking
Breaking change that won't be backward compatible
EditorConfig
0.17.2
Issues to support version 0.17.2 of the EditorConfig specification
Kind
Bug
Something is not working
Kind
Chore
Some tasks maintainig tasks
Kind
Documentation
Documentation changes
Kind
Enhancement
Improve existing functionality
Kind
Feature
New functionality
Kind
Testing
Issue or pull request related to testing
Packaging
About packaging the project for some platform
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
WIP
Work in progress (Assignee is working on this issue)
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
BaumiCoder/ecformat!40
Reference in a new issue
BaumiCoder/ecformat
No description provided.
Delete branch "feature/6-insert_final_newline"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?