BUG: code folding in editor

Below package body code example.

  1. copy code to Editor`s tab.
  2. try to fold first BEGIN at line 5
  3. code will be folded till the package end, not till procedure`s end.

create or replace package body PACKAGE_PKG as

PROCEDURE pay_process
IS
BEGIN

FOR A IN (SELECT DISTINCT h.ROWID row_id
          FROM dual
) LOOP
  l_currency_conversion_rate := A.currency_conversion_rate;

  UPDATE headers_all AT
  SET AT.DESTINATION =
          CASE WHEN AT.currency_code != utilities.get(AT.currency)
               THEN utilities.get(
                      p_amount => AT.tax
                    )
               ELSE AT.PAYMENT
          END
   WHERE AT.ROWID = A.row_id;
END LOOP;

END pay_process;

PROCEDURE help_me_i_was_hidded_by_bugly_folding_engine(
errbuf OUT NOCOPY VARCHAR2,
retcode OUT NOCOPY VARCHAR2
)
IS
BEGIN

g_put_to_log := TRUE;
g_date := ddate.canonical(p_date);

END i_was_hidded_by_bugly_folding_engine;

END PACKAGE_PKG;
/

I think there is a known bug with CASE statements causing the folder to become too greedy. If you remove the CASE, it works OK. See startfold-endfold problem

I have another example for this (Toad 13.2.0.258):

select xmlelement("Product",
           xmlelement("ItemNumber",pakuri_magento.magento_stammartnr(var.artnr)),
           xmlelement("ParentItemNumber",pakuri_magento.magento_stammartnr(var.stammartnr)),
           --
           --OPTIONEN (Durchmesser, Inhalt, Farbe)
           --
           xmlelement("Options",
             --Durchmesser
             --Value aus Durchmesser nvl(TEXT4,TEXT2) + " cm" auf Artikel
             case when nvl(var.text4,var.text2) is not null then
               xmlelement("Option",
                 xmlelement("OptionName",'diameter'),
                 xmlelement("OptionValue",
                   case when var.text4 is not null then
                     var.text4||' cm'
                   else
                     var.text2||' cm'
                   end
                 )
               )
             end,
             --Inhalt
             --Value aus TEXT3 oder Inhalt + Mengeneinheit auf Artikel
             case when nvl(var.text3,to_char(var.inhaltmng)) is not null then
               xmlelement("Option",
                 xmlelement("OptionName",'capacity'),
                 xmlelement("OptionValue",
                   case when var.text3 is not null then
                     var.text3||' '||nvl(pa_bez.mengeneinhbezkurz(var.inhaltmengeneinh),' l')
                   else
                     to_char(var.inhaltmng,'FM999990.09')||' '||nvl(pa_bez.mengeneinhbezkurz(var.inhaltmengeneinh),' l')
                   end
                 )
               )
             end,
             --Farbe (kleinste Sequenz "Farbe/Material exportieren", Fallback auf Stammartikel)
             --Value aus "Shoptext" > "Bezeichnung" auf Eigenschaftswert
             case when (select count(*)
                        from arteigenschaft arteig
                       where arteig.eigenschaft = 9
                         and art_id in (var.art_id,stamm.art_id)) > 0
             then
               (select xmlelement("Option",
                         xmlelement("OptionName",'color'),
                         xmlelement("OptionValue",
                           pakuri_bez.eigwerttext_kfarttext(arteig.eigwert,'E')
                         )
                       )
                  from (select eigenschaft,eigwert,
                               row_number() over (
                                 order by
                                 case when arteig.art_id = var.art_id
                                   then 1
                                   else 2
                                 end,
                                 sequenz
                               ) rn
                          from arteigenschaft arteig
                         where arteig.eigenschaft = 9
                           and arteig.logisch1 = 'J'
                           and art_id in (var.art_id,stamm.art_id)
                       ) arteig
                 where rn = 1
               )
             end
           )
         )
    from artikel var
    join artikel stamm on var.stammartnr = stamm.artnr
   where var.art_id = p_art_id;

If you try to fold the xmlelement("Options") function (beginning at line 7), it stops after the first case end case construct (line 22). Maybe this helps finding the problem.

Regards,
Julian