Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-21589

ClangFormat experimental plugin: SortIncludes option does not works

    XMLWordPrintable

Details

    Description

      Steps to reproduce:

      • set QTC_FORMAT_INSTEAD_OF_INDENT environment variable to 1
      • enable ClangFormat (experimental) plugin
      • restart Qt Creator
      • use code sample
      #include <string>
      #include <iostream>
      
      using std::string;using std::endl;using std::cout;
      
      int main(int,char*[]){cout<<string("hello, world")<<endl;return 0;}
      
      • create .clang-format inside project directory
        BasedOnStyle: Google
        
        AccessModifierOffset: -4
        AlignAfterOpenBracket: Align
        AllowShortFunctionsOnASingleLine: None
        AllowShortIfStatementsOnASingleLine: false
        AllowShortLoopsOnASingleLine: false
        BraceWrapping: 
          AfterClass:      true
          AfterControlStatement: true
          AfterEnum:       true
          AfterFunction:   true
          AfterNamespace:  false
          AfterStruct:     true
          AfterUnion:      true
          AfterExternBlock: true
          BeforeCatch:     true
          BeforeElse:      true
          SplitEmptyFunction: false
          SplitEmptyRecord: true
          SplitEmptyNamespace: true
        BreakBeforeBraces: Custom
        BreakConstructorInitializers: BeforeColon
        ColumnLimit:     90
        ConstructorInitializerAllOnOneLineOrOnePerLine: false
        ContinuationIndentWidth: 8
        DerivePointerAlignment: false
        IndentCaseLabels: false
        IndentWidth:     4
        SpacesBeforeTrailingComments: 1
        Standard:        Cpp11
        
      • select all (Crtl+A)
      • auto-indent selection (Ctrl+I)

      Expected result:

      #include <iostream>
      #include <string>
      
      using std::cout;
      using std::endl;
      using std::string;
      
      int main(int, char*[])
      {
          cout << string("hello, world") << endl;
          return 0;
      }
      

      Actual result:

      #include <string> // [ISSUE] not sorted
      #include <iostream>
      
      using std::cout; // [OK] sorted
      using std::endl;
      using std::string;
      
      int main(int, char*[]) // [OK] reformatted
      {
          cout << string("hello, world") << endl;
          return 0;
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            yvvan Ivan Donchevskii
            semenpiskarev semenpiskarev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes