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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not add newline to all strings #31

Merged
merged 2 commits into from
Jun 22, 2023

Conversation

amtoine
Copy link
Member

@amtoine amtoine commented Jun 21, 2023

cc/ @AucaCoyan

this PR moves the add_newline_at_end_of_file outside of format_inner.
the responsibility is not those of format_single_file, format_string does not add a newline to all strings anymore.

tests have been fixed 馃憤

one thing i'm struggling with is the following test

    #[test]
    fn remove_additional_lines() {
        let input = "let one = 1\n\n\n";
        let expected = "let one = 1\n";
        run_test(input, expected);
    }

which does not pass without the \n in expected 馃
any idea? 馃槙

this is because a standalone string might not be the content of a
file, so we do not want to always add a newline.
this commit writes `expected = input` now when both are equal after
removing the newlines.
@AucaCoyan
Copy link
Contributor

Hello! This test is for

If at the end of the file are there any multiple empty lines, just leave 1 line
I think we can remove it since format string doesn't do this from now.

Should we test the function format_file? we can write a file, format it and the test it. After that, we can delete the file.
What do you think? We can move that to another time too!

@AucaCoyan
Copy link
Contributor

As it is now, it is very valuable!
Later we would need to fix the failing test, but nonetheless is a step forward!
I'm allright with a merge right now 馃槃

Copy link
Contributor

@AucaCoyan AucaCoyan left a comment

Choose a reason for hiding this comment

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

All good!

@amtoine
Copy link
Member Author

amtoine commented Jun 22, 2023

greeeeat, thanks @AucaCoyan for the review 馃槍

@amtoine amtoine merged commit 1765f8e into nushell:main Jun 22, 2023
4 checks passed
@amtoine amtoine deleted the do-not-add-newline-to-all-strings branch June 22, 2023 16:58
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.

None yet

2 participants