Fold All collapse whole code in some cases?

Hi,

I noticed some strange (wrong?) behaviour when I try to Fold All code (collapse). But this happen only when is in code found specific code.

For example I have file with multiple cursors, like Cursor 1, Cursor 2, which are actually only different versions of same cursor I have in this file. When is in code found Case statement Fold All work wrong and collapse all cursors into 1, even are in file 2 or more. I attach also code below for easier test and how it should look like. This happen in 2025 R3. Is this a bug?

Regards,
Blacksmith

-- Cursor 1 ...
Select
  'File01',
  Cursor(
    Select

      Cursor( -- Cur1
        Select
          TBL.Attr1 Field1  -- << Using this fold Ok
--          RTrim(
--            Nvl(TBL.Attr1, '') ||
--              Case
--                When TBL.Attr1 Is Not Null And TBL.Attr2 Is Not Null Then '; '
--              End ||
--              Nvl(TBL.Attr2, '')
--          )        Field1 -- << Using that line Fold All collapse all
          
        From
          Dual
      ) "rec_cur1",
      
      Cursor( -- Cur2
        Select
          2 Field2
        From
          Dual
      ) "rec_cur2"

    From
      Dual
  ) "data"
From
  Dual
;

-- Cursor 2 ...
Select
  'File01',
  Cursor(
    Select

      Cursor( -- Cur1
        Select
          1 Field1
        From
          Dual
      ) "rec_cur1",
      
      Cursor( -- Cur2
        Select
          2 Field2
        From
          Dual
      ) "rec_cur2"

    From
      Dual
  ) "data"
From
  Dual
;

This is a defect although I am not sure exactly what about your code is causing it. We do have an outstanding issue logged with code folding problems with CASE in SQL statements, but the workarounds to that issue are not working for me with your sample. I will add your sample to the defect report.

Also, your sample code appears to work correctly for me as you’ve included it. If I uncomment lines 10-16 and add the missing , on line 9 then I see that trying to fold line 7 will fold the first two cursors. Is that the defect you’re seeing or are you seeing problems with the code you’ve included as-is? Your screenshot of the incorrect fold shows 64 lines in the Editor which your sample code does not have.

Michael

I used in an example Field1 just to show which one work (with simple field) and which doesn’t (with Nvl and Case expression which actually cause this). Current pasted code work. To see error you have to enable line 10-16 and disable 9 (or add comma as you did) to see result on my snapshot.

I just paste sample code so you don’t have to type all and is easier to check if you get the same. You see on snapshot 64 lines because I have some empty lines at the end. When I delete this I get on both cases 61.

So problem cause actually I think Case Expression in lines 12-14.

Why I use/need this: I use/store in same file lower also my previous versions. Then I collapse all code and copy my last version from line 2 to 34 (actually 7 visible lines) and paste it to destination (in that simple example). Real code have several 100 lines, so it time consuming to select all code by dragging mouse down or using keyboard, because you can over jump/select to old version lower and select too much.

Thanks for the clarification. I will add your example to the open case.

1 Like