GuyWithCookies
GuyWithCookies

Reputation: 640

Wrong indentation of multiline comments in VSCode with C/C++ extension

It seems that the clang formatter of the C/C++ extension has difficulties when indenting multiline comments.

I get the following format when using the formatter (so just the first line is formatted properly):

     /**
* @brief Does cool stuff
*
* @param param1
* @returns myresult
*/
     bool myFunction(bool param1);

However I would expect the format to be:

     /**
     * @brief Does cool stuff
     *
     * @param param1
     * @returns myresult
     */
     bool myFunction(bool param1);

My VSCode Clang Format style:

{BasedOnStyle: Google, IndentWidth: 3, ColumnLimit: 0, NamespaceIndentation: All, AlignTrailingComments: true}

Am I missing a Styleparameter or is this a bug in the formatter?

Upvotes: 2

Views: 1261

Answers (1)

Eric Backus
Eric Backus

Reputation: 1924

The problem is with ColumnLimit: 0. This somehow disables the indentation of the non-first-line-part of multi-line comments. (And this doesn't seem to be documented anywhere - I think it is a bug.) Probably the best workaround is to set ColumnLimit to some reasonable non-zero value.

Upvotes: 2

Related Questions