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

Rework multiline comments #164

Merged
merged 8 commits into from
Jul 26, 2023
Merged

Rework multiline comments #164

merged 8 commits into from
Jul 26, 2023

Conversation

FPtje
Copy link
Owner

@FPtje FPtje commented Jul 23, 2023

I was working on #163, and found myself in a bit of a rabbit hole: I tried to implement the following suggestion:

I guess what may be surprising here, is that returns and statements are counted differently. You can have a simple return, but not a simple statement instead of a return. Language wise a return is different from a statement, because it must be the last thing in a block. Conceptually though, it lives on the same level.

Maybe I can change the logic to one simple statement or a simple return

source

I found glualint to go in an infinite loop. The reason was because of how comment rendering logic depended on whether something is rendered multiline. But then the decision on whether to render something multiline depended on whether there were comments.

The solution is to remove the dependency "Comment rendering -> Multiline", and to only have it the other way around. This has quite some drastic consequences. Some attributes can be removed, others have to be reworked.

This PR keeps track of progress and TODOs.

TODO

  • Tables like {"a", "b", --[[comment]], "c"} are printed as multiline until the comment. After that it is printed single line
    • Personal note on how to solve this: inh field list forceMultiline, set to @hd.multiline or not null $ comments
  • Implement rendering comments after function arguments: foo(a, b --[[comment]], c)
  • Add some more tests regarding tables, function arguments.

self.StartPos - norm, -- Start
self.EndPos, -- End
64 * (1 - self.Life), -- Width
texcoord, -- Start tex coord
Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm really happy with this change. The comments used to all be collected and printed at the end. Now they're printed along with the argument. Besides that, having comments in function calls causes the function to be considered multiline.

@FPtje FPtje marked this pull request as ready for review July 25, 2023 16:22
Comment printing used to depend on whether the code was multiline. Now
this dependency is turned around: whether something will be rendered on
multiple lines depends on whether there are comments. This makes for a
much more natural way of formatting code.

This also adds support for comments next to function arguments.
@FPtje FPtje force-pushed the fp/rework-multiline-comments branch from 1a0a29c to b9f15a7 Compare July 26, 2023 09:25
@FPtje FPtje merged commit 08cb841 into master Jul 26, 2023
1 check passed
@FPtje FPtje deleted the fp/rework-multiline-comments branch July 26, 2023 10:33
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.

1 participant