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

Print function arguments on single line #176

Merged
merged 2 commits into from
Jan 1, 2024
Merged

Conversation

FPtje
Copy link
Owner

@FPtje FPtje commented Dec 31, 2023

Highly requested change. Changes pretty printing behavior from this:

timer.Create(
    "name",
    30,
    0,
    function()
        -- comment here
        if true then return end
    end
)

To this:

timer.Create("name", 30, 0, function()
    -- comment here
    if true then return end
end)

Requires somewhat rigorous testing to see if this is indeed what people want.

@FPtje
Copy link
Owner Author

FPtje commented Dec 31, 2023

Adding just a couple executables for people to test.

TESTING INSTRUCTIONS:
For those testing this, could you please try out the following:

  • Pretty print some stuff, and see if you like the result. Report in this PR if something is off
  • Run glualint test some-directory on your projects and report any problems it finds. This command will pretty print a file and then see if there are any syntax errors. It's a quick way of finding pretty print bugs.
    • If you find something, please pretty print the file manually to find the error, try to isolate the part that goes wrong, and post the code that breaks before pretty printing.
  • Please also let me know if you like this change!

glualint-pr-176-x86_64-linux.zip

glualint-pr-176-Windows.zip

@FPtje
Copy link
Owner Author

FPtje commented Dec 31, 2023

Open question for feedback: there is a comment -- format: multiline that forces something to be printed as multiline. Should this print stuff as follows?

-- format: multiline
render.DrawBeam(
    self.StartPos - norm,  -- Start
    self.EndPos,  -- End
    64 * (1 - self.Life),  -- Width
    texcoord,  -- Start tex coord
    texcoord + self.Length / 128,  -- End tex coord
    Color(
        -- Color (optional)
        Lerp(
            self.Life, 
            255, 
            50
        ), 
        Lerp(
            self.Life, 
            100, 
            50
        ), 
        255, 
        255
    )
)

The alternative I see is ignoring that comment altogether for function calls, which seems counter to its point.

@Yogpod
Copy link

Yogpod commented Dec 31, 2023

First format is with 1.24.6, second is with this pr, wondering if that can be adjusted with maybe an option
img

@FPtje
Copy link
Owner Author

FPtje commented Dec 31, 2023

You mean the newline between the first and second statement? That's something else entirely. That's on the wishlist here: https://github.com/FPtje/GLuaFixer/wiki/Feature-wishlist#configure-when-to-insert-empty-newlines-in-pretty-print-output

On a side note, could you put examples in code blocks next time? I had to watch the video many times before I understood what was going on.

@FPtje FPtje marked this pull request as ready for review January 1, 2024 12:00
@FPtje
Copy link
Owner Author

FPtje commented Jan 1, 2024

After getting some feedback on Discord, I think this is good to merge. For those who haven't tested yet, feel free to still test it and report issues. Thanks for trying it out and giving your opinions!

@FPtje FPtje merged commit 1c3b1a4 into master Jan 1, 2024
2 checks passed
@FPtje FPtje deleted the fp/change-function-rendering branch January 1, 2024 12:07
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.

2 participants