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

Ctrl-E R (reflow) is producing garbage when activated in single-line C++ comments

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • Qt Creator 13.0.1
    • Editors
    • None

      Unlike Emacs's Alt-Q, QtC's Ctrl-E R does not always take C++ context into account. If you are already in a multi-line comment, it will usually do the right thing and extend the comment with lines prefixed by // and indented correctly, but sometimes, it produces garbage. Most recent example (| indicates cursor position when hitting Ctrl-E R):

      #ifndef Q_OS_ANDROID
      // pthread_cancel may not unwind the cancelled thread's stack, so if a thread cancels itself|
      Q_CONSTINIT static QBasicMutex terminateMutex;
      #endif
      

      becomes

      #ifndef Q_OS_ANDROID // pthread_cancel may not unwind the cancelled thread's
      stack, so if a thread cancels itself Q_CONSTINIT static QBasicMutex
      terminateMutex; #endif
      

      and if I try to prevent it by adding blank lines as delimiters:

      #ifndef Q_OS_ANDROID
      
      // pthread_cancel may not unwind the cancelled thread's stack, so if a thread cancels itself|
      
      Q_CONSTINIT static QBasicMutex terminateMutex;
      #endif
      

      then that becomes

      #ifndef Q_OS_ANDROID
      
      // pthread_cancel may not unwind the cancelled thread's stack, so if a thread
      cancels itself
      
      Q_CONSTINIT static QBasicMutex terminateMutex;
      #endif
      

      expected: only the comment is wrapped, turning the one-line into a multi-line comment:

      #ifndef Q_OS_ANDROID
      // pthread_cancel may not unwind the cancelled thread's stack, so if a thread
      // cancels itself
      Q_CONSTINIT static QBasicMutex terminateMutex;
      #endif
      

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

            davschul David Schulz
            mmutz Marc Mutz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes