cmd/gofmt: nested list reformatting removes explicitly-written hierarchies in existing comments #55990
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
When saving some existing complex comments in some existing Go code that used nested lists inside a preformatted text block, I was quite astonished to find the list was flattened and the hierarchical information thus stripped.
The documentation states that nested lists aren't supported, which is fine, the rationale for the new syntax during the proposal phase made sense to me (at least as far as I was keeping up), but the formatter should leave the nested lists it finds well alone, especially as the author's original intent was already "preformatted block". It's the job of the renderer to fail to render nested lists if they're not supported, not the job of the formatter to strip valuable information on the presumption that the nested list should not have been there in the first place.
For anyone else astonished by this, I have been playing with two specific workarounds (I'm sure there are more):
Prepending
>
to the start of each line, markdown-quote-style. This fails to render, but rendering is not a problem I actually have, and the intent is very clear, so this is what I'm trying out for now:Putting a non-list line at the start of the comment also inhibits the auto-flattening:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
I saved a file with an existing comment that looked like this (with a few levels deeper)
What did you see instead?
The text was updated successfully, but these errors were encountered: