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

Code Formatting is Bonkers

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • Qt Creator 4.12.3
    • C/C++/Obj-C++ Support
    • None

    Description

      Note: clang-format plugin enabled, Beautifier disabled.

      It is impossible for me to deduce anymore what drives Qt Creator's code formatting settings. It used to be that the format-while-editing was driven by code style settings from project options - but that was before clang-format integration. So now there are no legacy code style settings, just clang format settings - but why are they shown (and out of sync!) if I have .clang-format files?? So I have proper .clang-format file in the root of the project, and in various sub-projects as needed but Qt Creator just ignores it. If I set the settings manually project wide, then they are wrong half the time, because the project includes git submodules, each with their own .clang-format, that the editor ignores (e.g. tabs vs. no tabs, etc). And even then sometimes Qt Creator just ignores the .clang-format file completely.

      Is there any method to this madness? Can someone explain what is the single source of truth that Qt Creator uses to configure the editor, formatting, etc? Note that the "default" editor settings are not usable since there's no single valid setting - either per project, or per system. And how to debug this?

      Also: Options > C++ > Code Style shows "Current project has its own overridden .clang-format file" - and there's no way to change it. If I go to Projects > Code Style > C++, the "Override Clang Format configuration file" checkbox is unchecked. I can hit Apply - nothing visually changes. The "Current project has its own overridden .clang-format file" is still there, and I have no idea at that point where does the formatting data come from. It seems that the project's .clang-format files don't work anymore - or at least there's nothing in Qt Creator that uses them, whether Beautifier is turned on or not.

      The "Open Used .clang-format Configuration File" context menu always brings up the correct format file, but it seems that the settings there are not consistently applied. For example:

      BreakBeforeBraces: Custom
      BraceWrapping:
        AfterFunction: true

       Yet all functions get reformatted with braces in-line (e.g. `void foo() {` not `void foo()\n{`). And so on. Since there's no feedback if any of the settings are incorrect - I can just type rubbish in the files and Qt Creator is quiet - I have no idea what, if anything is wrong.

      Attachments

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

        Activity

          People

            kandeler Christian Kandeler
            kubao Kuba Ober
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes