Home > OS >  CLion doesn't sort include statements on commit
CLion doesn't sort include statements on commit

Time:08-16

I'm using clang-format to define rules for sorting my include statements. This works perfectly when using the "Code > Reformat Code" button or pressing CTRL ALT L within a file.

However, even when setting the "Reformat code" checkbox in the CLion commit dialog, the include statements don't get sorted when commiting. For some reason other formatting tasks (such as fixing indentation) take place when commiting. It's just the include sorting that's missing.

Does anybody know why that is the case? Many thanks!

From the .clang-format file:

IncludeCategories:
  - Regex: '^<.*\.h>'
    Priority: 1
  - Regex: '^<[^.]*>'
    Priority: 2
  - Regex: '<.*>'
    Priority: 3
  - Regex: '.*'
    Priority: 3
IncludeBlocks: Regroup
SortIncludes: true

Commit Dialog

Format Settings

CodePudding user response:

JetBrains Support confirmed to be that this is a bug within CLion that they managed to reproduce on their system.

Hoping for it to be fixed in a future version :)

  • Related