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

feat: add inline struct field comments #52

Merged
merged 5 commits into from
Mar 25, 2024

Conversation

ttytm
Copy link
Member

@ttytm ttytm commented Mar 23, 2024

Allow for inline struct field comments. Comments above a struct field are prioritised.

Adds a fast track exit if comments has a length of 0.

@ttytm ttytm marked this pull request as draft March 23, 2024 15:42
@ttytm
Copy link
Member Author

ttytm commented Mar 23, 2024

Let's base it on #51, then this one can be simplified as well.

@ttytm ttytm force-pushed the feat/inline-struct-field-doc-comments branch from c6cd5de to f6c6305 Compare March 23, 2024 15:52
@ttytm ttytm marked this pull request as ready for review March 23, 2024 15:52
@ttytm ttytm marked this pull request as draft March 23, 2024 15:53
@ttytm ttytm marked this pull request as ready for review March 23, 2024 15:53
@ttytm
Copy link
Member Author

ttytm commented Mar 23, 2024

Alternatively, this could add the inline comment to the end of the above comments. Maybe with a linebreak if there are already other comments.

@JalonSolov
Copy link

I think trailing comments should stay trailing. Just as they are in the source when added.

@ttytm
Copy link
Member Author

ttytm commented Mar 23, 2024

I think trailing comments should stay trailing. Just as they are in the source when added.

I see and like that Idea. It requires to put some work into how the hover dialog is handled in general. Maybe as a separate feature?

@JalonSolov
Copy link

Hmm... visualizing...

How about this: If there is a doc comment above, show the first line of that by default. If there is no doc comment above, but there is a trailing comment, show the first line of the trailing comment. In either case, if there is more than one line of comments (including both doc and trailing), include a more... link that will expand the hover to show everything.

The reason for this is that when you're just learning how to use a struct, function, etc., you need the full text, but over time, you likely just need a quick reminder.

@ttytm
Copy link
Member Author

ttytm commented Mar 23, 2024

A change like this is of similar scope - working on the hover dialog itself - as showing a trailing comment in the hover dialog for struct fields with trailing comments. And tbh I don't see myself finding the time working on adding those conditions to the hover dialog yet.

@JalonSolov
Copy link

In the meantime, then, how about this...

If there's a doc comment, show it. It there's a trailing comment, show it with a marker in front to indicate trailing comment. If there's both, show both with a blank line between, and a marker to indicate trailing comment. Maybe something line this...

foo is a field that holds bars

... and this is the trailing comment

If you could get a wedge instead of ..., that would be fine, too. A > would work if nothing else, but it doesn't really set it off much.

@ttytm
Copy link
Member Author

ttytm commented Mar 23, 2024

Screenshot_20240323_213617

@ttytm ttytm force-pushed the feat/inline-struct-field-doc-comments branch from 19af0b3 to 88a15b7 Compare March 23, 2024 20:49
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

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

Excellent work.

@spytheman spytheman merged commit 609d66a into vlang:main Mar 25, 2024
12 checks passed
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.

3 participants