-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/tools/gopls: add an option to keep original line breaks in documentation comments #44684
Comments
…ks in hover Add a new documentation option `KeepOriginalLineBreaks` to keep original comment line breaks in hover. When the option is set to `true`, we add 2 spaces just before newline characters. This logic doesn't apply to code blocks and headers. Fixes golang/go#44684
Change https://golang.org/cl/329669 mentions this issue: |
Thank you for sending this CL, @ShoshinNikita, but I think we need to give this change a little more thought before we merge it. Adding a configuration option is a significant overhead, and I think we need a little more evidence that this change is worthwhile and would be widely used. @ShoshinNikita, can you speak to why you're in support of this? |
@stamblerre I thought the fact this issue is open and there're no any objections means it's ok to send a CL. Though I have no intention of using this feature myself, I believe the users should have an option to keep the original line breaks. I think it's a good argument:
For example, I find it easier to read comments with the original line breaks:
|
Typically I would recommend leaving a comment on the issue before taking it on, or seeing if it has a "help wanted" label. We usually try to mark issues that need a decision, but sometimes we may forget, so I would suggest checking in before starting work. I think we are still going to hold off on merging this until other folks weigh in. I see the argument, but the presentation of hover is very variable depending on your editor and how it shows the hover, so I think something like microsoft/vscode#14165 (which @hyangah linked on the original issue) really is a better bet. Adding a new configuration adds significant overhead and complexity to |
@gopherbot remove Documentation |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
This is follow-up on issue for vscode-go which turned out to be an issue with gopls.
Documentation comments inside code look like this:

It has line breaks so when you read comments while skimming yours or other peoples' code, you can expect comfortable and consistent text width. Comment width does not depend on viewport size, window size, font weight or system DPI.
Hover tooltips, however, changes its width and sometimes you may get very long documentation and sometimes it's too narrow.
In aforementioned issue, vscode-go developer stated that this behaviour is intended to make docs look like godoc html representation.
While it might sound like a good idea, it must be noted that godoc viewed inside browser as dedicated page.
Which means that:
Consumption behaviour inside text editor differs from godoc.
It is easier to read short snippets when they narrow. There also was a link to upstream issue of vscode for making tooltip width that mitigates this issue.
However, while it solves this issue, there is another one. Code of the package still remains important source of truth when you want to figure out why it works how it works. That means representation of docs becomes inconsistent: while you see continuous line in tooltip, it still narrow multi-line text in comments.
What did you expect to see?
Documentation with predictable text size that looks like documentation inside code comments which code author originally wrote.
What did you see instead?
The text was updated successfully, but these errors were encountered: