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

qmlformat: Add js Promise formatting support

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P3: Somewhat important
    • 6.9
    • 6.8.0
    • QML: Tooling
    • None
    • All

    Description

      performOperation(root.locking.lock(), "locking")
      .then(() => performOperation(aaa(), "opening damage"))
      .then(() => performOperation(bbb(), "removing file"))
      .then(() => {
          console.debug("moveToTrash: ", filePath);
          const success = Ibh.FileIo.moveToTrash(filePath);
          if (!success) {
              return Promise.reject("Failed to move file to trash");
          }
      {color:#000000}}).catch(error => {
          console.error("Operation failed:", error);
          errorOccurred(error);
      {color:#000000}});
       
      converts to:

      performOperation(root.locking.lock(), "locking").then(() => performOperation(aaa(), "opening damage")).then(() => performOperation(bbb(), "removing file")).then(() => {
          console.debug("moveToTrash: ", filePath);
          const success = Ibh.FileIo.moveToTrash(filePath);
          if (!success) {
              return Promise.reject("Failed to move file to trash");
          }
      {color:#000000}}).catch(error => {
          console.error("Operation failed:", error);
          errorOccurred(error);
      {color:#000000}});
       
       
      There is no line size limit, so additional .then statements will get written in the same line. I would really like to see them getting formatted like the first code.

      Attachments

        Issue Links

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

          Activity

            People

              qtqmlteam Qt Qml Team User
              kelteseth Elias Steurer
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes