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

Moving code blocks (CTRL+Shift) does not auto indent if first line is a comment line

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • Qt Creator 4.10.1
    • Qt Creator 4.8.1, Qt Creator 4.9.0-beta1, Qt Creator 4.9.0-rc1, Qt Creator 4.9.0
    • None
    • Linux/X11, Windows

    Description

      When moving a code block into a new scope (e.g. if {}) then auto indenting of the code block only works correct, if the first line is not a comment line.

       

      // example
         if (loadingAreaOK)
            {
            }
         // now let the model use the area progress                // -1
         _wptProgressModel->setAreaProgress(_areaProgress);        // -2
      
      

      Mark the two lines (-1 and -2) and use the code move opration in the editor using <CTRL + Shift + Cursor Up> to move the block into the if scope.

       

      The result should look like this

       

      // expected result
         if (loadingAreaOK)
            {
            // now let the model use the area progress
            _wptProgressModel->setAreaProgress(_areaProgress);      
            }
      

      But the result you get is

       

       

      // actual result
         if (loadingAreaOK)
            {
         // now let the model use the area progress
         _wptProgressModel->setAreaProgress(_areaProgress);      
            }
      
      

       

      If you swap line -1 and -2 to have the code line above the comment line and move these, the code moving auto indents as expected: the lines are shifted to the indent of the 'if' scope.

      Work around:

      After moving the line press <CTRL>+i to auto indent.

      However it would be nice to check, if the selected lines are not only comment lines and understand the selection as a code block.

       

      Attachments

        Activity

          People

            yvvan Ivan Donchevskii
            moellney Michael Möllney
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: