Closed SakurajimaMaii closed 4 months ago
Yes, that's the "hanging indent"; you can use --hanging-indent=0
Hi, since KDoc is Markdown by default, an indentation of four or more spaces converts the line to a code block. I think it would make sense to disable leading spaces on line breaks entirely. I had to disable the IntelliJ plugin because of that.
since KDoc is Markdown by default, an indentation of four or more spaces converts the line to a code block.
That's not actually exactly how Markdown behaves; both full Markdown renderers (like the bundled Markdown renderer in IntelliJ, shown below), as well as Dokka itself (the tool which renders KDocs in HTML) properly handle this:
However, IntelliJ's in-IDE KDoc preview renderer doesn't seem to use a full-blown markdown renderer, and among other things it misinterprets this. In fact, when the ktfmt team integrated kdoc-formatter into ktfmt as the new doc comment formatter, they changed the default indentation from 4 to 3, which works around this IntelliJ bug.
At the time I didn't change kdoc-formatter since I didn't want to cause needless diffs for people with existing codebases. But this issue has come up multiple times so I guess it's better to just change it. So, I've just released* version 1.6.4 which changes the default from 4 to 3 -- and I also made it possible to override it directly in the KDoc IDE settings (similar to the --hanging-indent
command line flag.)
*: Well I've uploaded it to the plugin marketplace; it has to be manually verified before it's made available, which can take up to two business days. You can also download and install from the releases page here: https://github.com/tnorbye/kdoc-formatter/releases/tag/v1.6.4
Taking the screenshot as an example, is there a way for me to cancel the indentation of the line before aaaaaaa? This is what I expected