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

Code folding bug when saving file

    XMLWordPrintable

Details

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

    Description

      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

      Attachments

        1. 1-original-file.png
          1-original-file.png
          80 kB
        2. 2-added-newline.png
          2-added-newline.png
          80 kB
        3. 3-folded.png
          3-folded.png
          77 kB
        4. 4-saved-file.png
          4-saved-file.png
          78 kB
        5. c.c
          0.1 kB

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes