Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim trailing duplicated TokenNewline in VerticalFormat #48

Merged
merged 1 commit into from
Feb 23, 2022

Conversation

minamijoyo
Copy link
Owner

The previous implementation of removeDuplicatedNewLine removed consecutive 3 or more duplicated TokenNewline tokens. This was expected between blocks and at the end of the file. However, when removing a nested block in a root block and formatting only a body of the block, an extra TokenNewline will be left at the end.

While at the end of the file, there should be at least one TokenNewLine, so we can trim it into only one TokenNewline at the end. We should not trim the last newlines because the last one means the end of line.

The fix does not currently truncate trailing newlines in blocks when formatting the entire file. I think it should be done, but I will postpone it because the implementation would be complicated.

This is a small breaking change for vertical format, but I think it's a bug fix and I expect that the most of the users doesn't care about it, so this will be included in the next patch release.

The previous implementation of removeDuplicatedNewLine removed
consecutive 3 or more duplicated TokenNewline tokens. This was expected
between blocks and at the end of the file. However, when removing a
nested block in a root block and formatting only a body of the block, an
extra TokenNewline will be left at the end.

While at the end of the file, there should be at least one TokenNewLine,
so we can trim it into only one TokenNewline at the end. We should not
trim the last newlines because the last one means the end of line.

The fix does not currently truncate trailing newlines in blocks when
formatting the entire file. I think it should be done, but I will
postpone it because the implementation would be complicated.

This is a small breaking change for vertical format, but I think it's a
bug fix and I expect that the most of the users doesn't care about it,
so this will be included in the next patch release.
@minamijoyo minamijoyo merged commit a1b4982 into master Feb 23, 2022
@minamijoyo minamijoyo deleted the fix-vertical-format branch February 23, 2022 08:54
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.

1 participant