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

Ternary operator in initializer breaks indentation

    XMLWordPrintable

Details

    Description

      In my code, I have an initializer that takes the following form...

      Foo::Foo(QString possiblyEmpty)
          : someQStringMember{possiblyEmpty.isEmpty() ? "replacement" : possiblyEmpty},
            anotherMember{"Ĉu vi komprenas ĉi tiun frazon? ;)"}
      {
          // life carries on...
      }
      

      ...the idea being that someQStringMember should never be empty, even if

      {possiblyEmpty}

      is empty. The problem with this is that Qt Creator doesn't correctly parse this, thinks that anotherMember{"something nice"} is part of the initializer list for possiblyEmpty, and breaks formatting for the entire constructor body.

      This issue can be worked around by wrapping the ternary operation in parentheses, but it would be nice to have a proper fix.

      Attachments

        Issue Links

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

          Activity

            People

              kandeler Christian Kandeler
              lorendb Loren Burkholder
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes