Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-116765

qmlformat: unnecessarily formats single line to multiple lines

    XMLWordPrintable

Details

    • a7f88b189 (dev), 6f2ea69f1 (6.9), c3532b39a (6.8), 7aa9847f3 (tqtc/lts-6.5)

    Description

      If the developer follows the example in 
      https://doc.qt.io/qt-6/qml-codingconventions.html#javascript-code

      "If the script is a single expression, we recommend writing it inline:

      Rectangle { color: "blue"; width: parent.width / 3 }"

      And writes e.g. 

      Button { text: "PRESS ME!"; width: parent.width / 3 }

      Qmlformat unnecessarily reformats it: 

      Button {
          text: "PRESS ME!"
          width: parent.width / 3
      }

      That being said, I personally like the the multiline version better from readability point of view. Could it be that the example code in QML Coding Conventions should be updated if qmlformat is already doing the right thing ?  

       

       

      Attachments

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

        Activity

          People

            semih.yavuz Semih Yavuz
            jannej Janne Juntunen
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews