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

Place each statement of default snippets on an individual line

    XMLWordPrintable

Details

    Description

      Currently, default snippets like "NumberAnimation with target" have each statement on the same line:

      import QtQuick 2.2
      
      Rectangle {
          id: window
          width: 600
          height: 600
      
          Rectangle {
              id: rect
              width: 60
              height: 60
              anchors.centerIn: parent
              color: "green"
      
              NumberAnimation { target: object; property: "name"; duration: 200; easing.type: Easing.InOutQuad }
          }
      }
      

      This is not a nice way of writing code for the following reasons:

      1. Adding a new property means you may need to wrap the line.
      2. Removing a property becomes more difficult (instead of just deleting a whole line).
      3. Changing the name or value of a property becomes more difficult; you can't just home/end your way around, you need to use CTRL + left/right to get to individual properties.
      4. What it saves on lines of code, it loses on readibility. It's hideous to look at. I know that's subjective, but even Tools > QML/JS > Reformat File agrees with me on this:
        import QtQuick 2.2
        import QtGraphicalEffects 1.0
        
        Rectangle {
            id: window
            width: 600
            height: 600
        
            Rectangle {
                id: rect
                width: 60
                height: 60
                anchors.centerIn: parent
                color: "green"
        
                NumberAnimation {
                    target: object
                    property: "name"
                    duration: 200
                    easing.type: Easing.InOutQuad
                }
            }
        }
        
      5. It impedes the usefulness of things like git blame.

      Attachments

        Activity

          People

            mitch_curtis Mitch Curtis
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: