R2021b - code folding in switch/case not fully available

14 ビュー (過去 30 日間)
Gabriele
Gabriele 2021 年 10 月 7 日
編集済み: Malcolm Fry 2022 年 10 月 12 日
Hello,
I've moved from R2021a to R2021b, and I have an issue with code folding in the editor for switch/case statements.
In the R2021a editor, I could fold the entire "switch...end" block, and it was also possible to separately fold the code block associated with each "case", see below:
Now, with R2021b, I can see how to fold the entire "switch...end" code clock, but I do not see anymore the possibility of folding each "case", see below:
I checked the Editor preferences, but I could not find any specific option to enable/disable code folding of "case" blocks. I could only find the option related to the entire swith
Do you know how to enable the possibility of folding each "case" in R2021b?
Thanks,
Gabriele

採用された回答

Prateek Rai
Prateek Rai 2021 年 10 月 13 日
Hi Gabriele,
The case folding wasn't removed intentionally. MATLAB has switched to a new editor from R2021b and so, it has a new backend for the code folding data. The editor does not recognize switch case branches as a foldable construct.
The concerned development team is aware of the same and the feature might be available in a future MATLAB release.
Thanks
  5 件のコメント
Mark Magdaleno
Mark Magdaleno 2022 年 5 月 12 日
Ths editor in 2021B has many issues including this code folding issue. Treating this as an option to add back in in the future is not acceptable. I was perfectly happy with the old editor thnaks you. This new editor is no end of headaches. This new editor smells a lot like Jive Editor and CrAppdesigner in its look and feel. Thats not a compliment by the way.
Tobias Panitz
Tobias Panitz 2022 年 5 月 18 日
Hey, can you please tell me that the code folding is gonna be in an update for R2022a?
It is heinously annoying that you cannot fold the cases.

サインインしてコメントする。

その他の回答 (3 件)

Samuel Scott
Samuel Scott 2022 年 3 月 8 日
I'd just like to add my two cents. This omission in the new editor is very problematic for our code base. We use many switch-case blocks and make use of code folding for more rapidly navigating the code base. Since the new update this is now impossible and all the added scrolling makes for much slower development. Personally I don't think the %% is a great solution and look forward to this being remedied in a future version.
  2 件のコメント
Tobias Panitz
Tobias Panitz 2022 年 3 月 9 日
Make it four.
This whole company policy of saying "might be available in a future release" is really annoying for something that used to work no problem.
ET
ET 2022 年 3 月 21 日
編集済み: ET 2022 年 3 月 21 日
Agreed. I heavily use switch/case block in my code and now it has become very hard to manage. The suggestion to go back and include hundreds (maybe thousands) of %% in existing files because Matlab staff accidentally removed a this feature and are not planning to immediately fix it? This is both lazy and irresponsible.

サインインしてコメントする。


Jacky Tsai
Jacky Tsai 2022 年 6 月 28 日
Hi All,
This issue has been fixed in R2022a Update 3.
  3 件のコメント
Gabriele
Gabriele 2022 年 7 月 22 日
Good to see the issue has eventually been solved! Thanks!
Malcolm Fry
Malcolm Fry 2022 年 10 月 12 日
編集済み: Malcolm Fry 2022 年 10 月 12 日
R022a Update 5. Although the update certainly helps it seems it is not fully robust? It now seems that clicking the '+' to expand a block, at times, is merely adding an extra set of '...' at the end of the line, and the code does not expand when the '+' is clicked. The same applies when the left margin is showing '-'; sometimes '-' toggles that extra set of '...'. These spurious '...' come and go; at times the '+' & '-' does work as required. Has anyone else seen this? 'Copying and pasting' all the content into a blank document [saveas new file] had some temporary success, although it was not comprehensive nor always persistent. At times I have seen a very long list of multiple '...' on the same row. A workaround is to find the '...' that may be beyond %notes, off the RHS of the screen, at the end of a line; and to click on this '...'; nevertheless that obviates the intention of the '+' at the left margin. At times the '-' sign in the left margin shows even when the code it refers to is already folded. Pressing the '-' adds the second '...'.

サインインしてコメントする。


Prateek Rai
Prateek Rai 2021 年 10 月 9 日
To my understanding, you want to fold each "case" block in R2021b.
One possible workaround could be-
Step 1: Go to Editor preferences and enable Code Folding for "Sections" and "Switch/case blocks".
Step 2: Now you can use %% to create sections after each "case" blocks and this will give you an option for folding them.
The code will look like:
int i =1
switch 1
case 1
%%
p =2;
case 2
%%
p=3;
end
This time you will get the option for code folding after each case.
  3 件のコメント
thierry Lanoe
thierry Lanoe 2022 年 3 月 1 日
Hello Prateek
I fully agree with Gabriele the previous behavior of code folding for Switch case was much better
i will use your workaround tips but this is cleraly less convenient
jimmydx
jimmydx 2022 年 6 月 15 日
編集済み: jimmydx 2022 年 6 月 15 日
I need this to come back as well. I'm on R2022a and this has made a mess on some of my code that heavily relies on many switch cases. It is not feasible for me to create sections for all cases, especially since I need cases to be folded initially, but not sections. Is there any way to add this as feedback for future release development?

サインインしてコメントする。

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by