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

Code indentation in lambda functions incorrect

XMLWordPrintable

      When typing multi-line C++ code inside a lambda function that is indented relative to the outer scope, the editor ignores the lambda indentation and indents the lambda body relative to the outer scope.

      For instance, try typing this piece of code:

      std::thread // 1
      (
          []() //2
          {
              try //3
              {
              }
              catch()
              {
              }
          }
      ).detach();
      

      Note that the lambda body is indented deeper than the std::thread declaration scope (1). Yet as I type the lambda body, the editor puts closing braces and the cursor after a newline to the lambda level (2) instead of one level deeper (3).

        1. qtcreator-2025-06-06_15.06.52.mkv
          2.42 MB
          Andrey Semashev
        2. simplescreenrecorder-2025-06-06_14.53.21.mkv
          904 kB
          Andrey Semashev
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            hjk hjk
            lastique Andrey Semashev
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes