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

QML required properties can confuse auto indentation

    XMLWordPrintable

Details

    • Linux/X11
    • c57f6a703b611e08e86365d8a98a58cbc9a5bd94 (qt-creator/qt-creator/master)

    Description

      I was coding today and encountered a bug where QtCreator's automatic indentation of lines was shifted way over to the right, so every time I hit return to make a new line, it began each line with too much indentation.

      After some experimentation, I find that this issue is triggered by the combination of two factors:

      • The use of the new "required property" feature of QML
      • The use of an object literal, i.e.
        let obj = {"property": value}

      The indentation problem occurs for every line in the file following the object literal.

      Here is a file that reproduces the issue:

      Bad Indentation.qml
      import QtQuick 2.15
      
      Item {
          id: theFoo
      
          required property Item theItem
      
          function foo() {
              theItem.foo("The issue is exacerbated if the object literal is wrapped onto the next line like so:",
                          {"foo": theFoo})
          }
      }
      

      All lines after line 10, with the object literal, will be improperly indented. If you use QtCreator's auto-indent feature over a selection or the whole file, it will also confuse the indentation.

      Note that the removal of "required" from line 6 causes indentation to function normally again.

      Note that I do use FakeVim, but I was able to reproduce this issue with FakeVim turned off, so I don't believe it to be related.

      Attachments

        Issue Links

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

          Activity

            People

              fawzi Fawzi Mohamed
              nhourt Nathan Hourt
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes