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

Wrong auto indentation after curly brackets init that uses the conditional operator 

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • Qt Creator 6.0.1
    • C/C++/Obj-C++ Support
    • Windows

    Description

      Qt Creator starts to wrong the auto-indentation of the code after a variable initialization that uses curly brackets init with the conditional operator.

       

      An example below

      #include <iostream>
      #include <QString>
      
      int main(int argc, char *argv[])
      {
         int var1 = -24, var2 = 5774;
         auto longer { QString::number(var1 ).size() >= QString::number(var2).size() ? &var1 : &var2 };
         std::cout << "The int with more chars is " << *longer << std::endl;
      }
      

      If I select the whole text and I auto-indent the code the result is:

      #include <iostream>
      #include <QString>
      
      int main(int argc, char *argv[])
      {
         int var1 = -24, secondInt = 5774;
         auto longer { QString::number(var1 ).size() >= QString::number(var2).size() ? &var1 : &var2 };
                       // Starting from now the indentation is wrong
                       std::cout << "The int with more chars is " << *longer << std::endl;
                     }
      

       

      Attachments

        Activity

          People

            artem.sokolovskii Artem Sokolovskii
            lorenzoaldrighetti Lorenzo Aldrighetti
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: