Skip to content

Fix IDE formatting of correctly formatted files with trailing newlines - #9683

Closed
mszabo-wikia wants to merge 1 commit into
facebook:masterfrom
mszabo-wikia:fix-formatting-of-trailing-newlines
Closed

Fix IDE formatting of correctly formatted files with trailing newlines#9683
mszabo-wikia wants to merge 1 commit into
facebook:masterfrom
mszabo-wikia:fix-formatting-of-trailing-newlines

Conversation

@mszabo-wikia

Copy link
Copy Markdown
Contributor

Since D60978552, we special-case removing a range of lines during IDE formatting so that T188437747 does not rear its ugly head. However, when document-formatting a file that is already correctly formatted save for some spurious trailing newlines, this logic ends up consuming the last non-newline line. So, only shift the start offset if the last changed line wasn't a trailing line that got removed.

Add a test and wire up hh_single_ide_format with the OSS dune build so that IDE format tests can be run.

@meta-cla meta-cla Bot added the CLA Signed label Dec 4, 2025
@meta-codesync

meta-codesync Bot commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D88329959. (Because this pull request was imported automatically, there will not be any future comments.)

@mszabo-wikia
mszabo-wikia force-pushed the fix-formatting-of-trailing-newlines branch from 0f26849 to 419cd56 Compare December 10, 2025 11:21
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@mszabo-wikia has updated the pull request. You must reimport the pull request before landing.

@mszabo-wikia
mszabo-wikia force-pushed the fix-formatting-of-trailing-newlines branch from 419cd56 to f338f52 Compare January 6, 2026 17:28
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@mszabo-wikia has updated the pull request. You must reimport the pull request before landing.

Since D60978552, we special-case removing a range of lines during IDE
formatting so that T188437747 does not rear its ugly head.
However, when document-formatting a file that is already correctly
formatted save for some spurious trailing newlines, this logic ends up
consuming the last non-newline line. So, only shift the start offset
if the last changed line wasn't a trailing line that got removed.

Add a test and wire up `hh_single_ide_format` with the OSS dune build
so that IDE format tests can be run.
@mszabo-wikia
mszabo-wikia force-pushed the fix-formatting-of-trailing-newlines branch from f338f52 to bc21be9 Compare January 19, 2026 14:49
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@mszabo-wikia has updated the pull request. You must reimport the pull request before landing.

@meta-codesync

meta-codesync Bot commented Jan 23, 2026

Copy link
Copy Markdown
Contributor

This pull request has been merged in 21784c0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants