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

qmlformat IndentingLineWriter: Indenting after property without binding

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • 6.8
    • 6.8
    • QML: Tooling
    • None
    • All

    Description

      For the following code:

      Item {
          property int propWithoutBinding
      
          function a() {
              ++i;
          }
      } 

      This would confuse the IndentingLineWriter and the resulting indentation will be:

      Item {
          property int propWithoutBinding
      
          function a() {
              ++i;
          }
          } 

      We found a fix by modifying the handleTokens function from qqmldomcodeformatter.cpp for the case BindingOrObjectdefinition, we add a case for T_FUNCTION:

              case StateType::BindingOrObjectdefinition:
                  switch (kind) {
                  case QQmlJSGrammar::T_COLON:
                      enter(StateType::BindingAssignment);
                      break;
                  case QQmlJSGrammar::T_LBRACE:
                      enter(StateType::ObjectdefinitionOpen);
                      break;
                  // property definition without binding:
                  case QQmlJSGrammar::T_FUNCTION:
                      leave(true);
                      enter(StateType::FunctionStart);
                      break;
                  }
                  break; 

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            ovidiu.tepescu Ovidiu Tepescu
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes