Closed mitchellwrosen closed 2 years ago
Thanks for the report! If you just want to get rid of this failure, you can move the comment -- Remove this when the file is ready to be auto-formatted
to the next line (such that {- ORMOLU_DISABLE -}
does not have succeeding non-whitespace characters on its line), then everything works fine.
This is a minimized example for the issue:
{- ORMOLU_DISABLE -} -- foo
which is formatted
{- ORMOLU_DISABLE -}
-- foo
Here, we do not consider the input to contain a magic comment due to non-space characters being on the remaining line, see the guard (isAllSpace s3)
line at the bottom:
The AST does differ as the output then does contain a magic comment, so the input is a ParsedSnippet
while the output is a RawSnippet
.
The easiest fix I can think of is to consider such magic-ish comments to actually be magical, and to preserve the remaining line content; this issue report is some evidence that people expect this behavior. I implemented this fix in the amesgen/issue-856
branch.
Side note: Despite being my first suspicion, this issue is not related to the rework of disabled regions handling (#773), but does also occur on <0.3.0.0 for the same reasons.
Describe the bug
The AST differs when this file is formatted.
To Reproduce
Format this file: https://github.com/unisonweb/unison/blob/6992f245675926d2a5f5b2c2f17545e877c87678/parser-typechecker/src/Unison/Codebase/SqliteCodebase.hs
--debug output
Environment
ormolu-0.4.0.0