nushell / nufmt

MIT License
64 stars 8 forks source link

do not add newline to all strings #31

Closed amtoine closed 1 year ago

amtoine commented 1 year ago

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 :+1:

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 :thinking: any idea? :confused:

AucaCoyan commented 1 year ago

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 commented 1 year ago

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 😄

amtoine commented 1 year ago

greeeeat, thanks @AucaCoyan for the review :relieved: