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

Upon saving, ClangFormat replaces tabs with spaces in one-line functions

    XMLWordPrintable

Details

    • 6f745e0a4def20176f7ae5d1609cabe847de466f (qt-creator/qt-creator/4.9)

    Description

      Steps to reproduce:

      • Delete ~/.config/QtProject
      • Launch Qt Creator, enable the experimental ClangFormat plugin, and restart
      • Open the attached project in Qt Creator — the project contains a .clang-format file specifying that tabs should be used for indentation
      • Open main.cpp
      • Move the cursor after the open curly brace and press Enter
      • Type return 0; (do not press Enter)
      • (Note that the return 0; line is indented using a tab — good)
      • File > Save
      • (Note that now the return 0; line is indented using 4 spaces — bad)

      If I run clang-format main.cpp from the command line, it correctly indents using a tab.

      This bug seems to happen only for one-line functions. If the function has 2 or more lines, it correctly indents using tabs.

      Attachments

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

        Activity

          People

            yvvan Ivan Donchevskii
            smokris Steve Mokris
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes