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

Lightbulb "Apply Changes to definition / declaration" changes line breakage

    XMLWordPrintable

Details

    • Windows
    • 768494b61 (15.0)

    Description

      I really like the lightbulb feature, that helps renaming parameter names in functions/methods.

      What I do not like is, that it changes formatting of the parameter listing of the function declaration or definition (depending on what to adapt to).

      Starting point:

      #include <QDebug>
      
      // declaration
      void foo(
            int i,
            float f
            );
      
      // definition
      void foo(
            int i,
            float f
            )
         {
         qDebug() << i << f;
         }
      
      int main()
         {
         foo(1, 2.);
         }
       

      E.g., when I rename the second parameter "f" in the declaration to "f1" then a lightbulb pops up and asks me if I want to "Apply changes to definition". Clearly, I want this.
      But look at the result:

      #include <QDebug>
      
      // declaration
      void foo(
            int i,
            float f1
            );
      
      // definition
      void foo(int i,
               float f1
               )
         {
         qDebug() << i << f1;
         }
      
      int main()
         {
         foo(1, 2.);
         }
       

      In the definition the parameter was changed to f1 and the places where it is used in the function were adapted, too. Great!
      But, the formatting of the definition changed:
      before:

      // definition
      void foo(
            int i,
            float f
            )
         {
         qDebug() << i << f;
         }
      

      after:

      // definition
      void foo(int i,
               float f1
               )
         {
         qDebug() << i << f1;
         }
      

      This breaks the original parameter listing formatting.
      I would expect to have the result:

      // definition
      void foo(
            int i,
            float f1
            )
         {
         qDebug() << i << f1;
         }
      

      In the current behavior, every time I have to go the definition (normally in another file) and change the formatting back. This is tedious.

      It would be great if the formatting of the adapted parameter listing would be kept.

      Attachments

        1. image-2024-08-01-17-43-24-194.png
          image-2024-08-01-17-43-24-194.png
          109 kB
        2. ParameterRafactoring.gif
          ParameterRafactoring.gif
          293 kB
        3. ParameterRafactoring.zip
          0.8 kB
        4. qt_style.xml
          2 kB

        Issue Links

          For Gerrit Dashboard: QTCREATORBUG-31293
          # Subject Branch Project Status CR V

          Activity

            People

              kandeler Christian Kandeler
              moellney Michael Möllney
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes