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

Code folding bug when saving file

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • Qt Creator 2.4.1, Qt Creator 2.5.0, Qt Creator 2.5.2, Qt Creator 2.6.0-rc, Qt Creator 14.0.0
    • Editors
    • None

      When I save file with some code folded, unexpected blocks of code could pop out suddenly.

      To reproduce this bug in Qt Creator

      • open file c.c
        int main()
        {
            // Qt Creator code folding bug
            return 0;
        }
        
      • add few empty lines just after comment by pressing Return key
        int main()
        {
            // Qt Creator code folding bug
            
            return 0;
        }
        
      • fold main() function by clicking on minus sign
      • save file

      Expected: nothing visual should happen
      Unexpected: after saving file return 0; pops out without any reason

      Some details.

      It's probably somehow related to Editor's behavior on dealing with empty lines. Editor tries to remove any redundant whitespace characters on each empty line right before saving document. If I turn this feature off then everything works as expected.

      You can untick this feature here:
      Tools - Options - Text Editor - Behavior - Cleanups Upon Saving - [ ] Clean whitespace

        1. 1-original-file.png
          80 kB
          Nikita Sinitsa
        2. 2-added-newline.png
          80 kB
          Nikita Sinitsa
        3. 3-folded.png
          77 kB
          Nikita Sinitsa
        4. 4-saved-file.png
          78 kB
          Nikita Sinitsa
        5. c.c
          0.1 kB
          Nikita Sinitsa
        6. Screenshot from 2025-01-28 11-16-11.png
          12 kB
          Jarek Kobus
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            davschul David Schulz
            ua45tj Nikita Sinitsa
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes