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

[clang-format] formatter only formats changed lines

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • Qt Creator 7.0.2
    • C/C++/Obj-C++ Support
    • None

    Description

      there is a small issue with the clang-format plugin.

      consider this code:

      struct foo {
          int   bar;
          float baz;
      };

      when clang-format's alignment options are used, `bar` and `baz` are aligned.

      now, if the code is changed so something like:

      struct foo {
       a_really_really_long_type bar;
       float baz;
      }; 

      saving the file with qt-creator will run clang-format, but not on the full file, but only on the changed lines. so `bar` and `baz` are not aligned, since the line declaring `baz` has not been changed. if this line is modified however, saving the file will align `bar` and `baz` as expected.


      i suppose there is some kind of application logic which does not run clang-format on the full file, but only on modified lines. this is a bit surprising to me, as i'd expect it to format the whole file. it smells more like a bug than a feature, but if it's a feature, maybe it can be exposed via an option?

      Attachments

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

        Activity

          People

            artem.sokolovskii Artem Sokolovskii
            timblechmann tim blechmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes