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

Always print source of formatted file unless --check is specified #2205

Merged
merged 3 commits into from
Jun 19, 2023

Conversation

paulcadman
Copy link
Collaborator

This PR was already merged in #2173, but main was subsequently forced pushed as part of the 0.4.0 release and these changes were erased by mistake.

This PR changes the behaviour of the formatter when run on files that are already formatted. Previously the source of a file that was already formatted was not output by the formatter.

After this PR, the formatter always outputs the contents of a formatted file (when used on a single file, and if the --check option is not specified).

If the format: false pragma is set then the source is echoed verbatim, without highlighting (because it's not possible to get the highlighting without the formatting).

This probably helps implementing the formatter in the vscode extension, see anoma/vscode-juvix#98

Previously the source of a file that was already formatted was not
output by the formatter.

If the `format: false` pragma is set then the source is echoed verbatim,
without highlighting.
@paulcadman paulcadman added enhancement New feature or request juvix-formatter labels Jun 19, 2023
@paulcadman paulcadman added this to the 0.4.1 milestone Jun 19, 2023
@paulcadman paulcadman requested a review from vrom911 June 19, 2023 13:37
@paulcadman paulcadman self-assigned this Jun 19, 2023
Copy link
Contributor

@vrom911 vrom911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@lukaszcz
Copy link
Collaborator

What happens when there is a syntax error?

@paulcadman
Copy link
Collaborator Author

What happens when there is a syntax error?

The corresponding parse error will be printed to stderr

@lukaszcz
Copy link
Collaborator

I hope the VSCode extension can handle that error and won't make the code disappear.

@paulcadman
Copy link
Collaborator Author

I hope the VSCode extension can handle that error and won't make the code disappear.

Good point! @vrom911 can you help with this?

@vrom911
Copy link
Contributor

vrom911 commented Jun 19, 2023

This is the case. Current problem was with the different expectations of the output with the format command from Juvix itself 🙂
I will test it more with the new release of Juvix, when it is done 🙂

@paulcadman paulcadman merged commit 7840f9f into main Jun 19, 2023
@paulcadman paulcadman deleted the format-always-output-source branch June 19, 2023 14:15
jonaprieto pushed a commit to anoma/vscode-juvix that referenced this pull request Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request juvix-formatter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants