Code Folding is broken, can't see hundreds of lines of code in Editor

48 visualizaciones (últimos 30 días)
Val
Val el 24 de Oct. de 2024
Comentada: Jordi el 11 de Jul. de 2025
Hi everyone, I'm having a serious issue within the MATLAB Editor. I really like writing my code using sections (as defined by %% syntax) and then enabling code folding for sections for readability.
Recently I opened a .mat file I used very regularly a few months ago and found that this code folding is very broken. The plus/minus icons next to the line numbers are not always aligned with the sections or really anything that can be code-folded, at least as far as I can tell. Also, and most critically, I can't unfold enough to see all of my code. The best I can do is display lines 1-232 and lines 783-951, but everything between 232-783 is completely inaccessible. There is a clickable ellipsis at the end of line 232, but clicking it does absolutely nothing (I saw the same clickable ellipsis in other lines, and clicking it would unfold some more code). Also, line 232 is not the end of that section of code.
Thankfully, if I hit "Run" then the whole code runs with no problem. But this is still a huge issue because I can't access 500+ lines of my code to edit them. I have attached a screenshot of my editor (with the code itself greyed out) showing exactly what I mean.
I've had similar code folding issues before but they were fairly easy to resolve by messing with the code folding settings in "Preferences" or just restarting MATLAB. Doing so now doesn't help at all. Any help with this would be immensely appreciated.

Respuestas (1)

Saurabh
Saurabh el 24 de Oct. de 2024
Movida: the cyclist el 24 de Oct. de 2024
Hi @Val,
I experienced the same issue but could fix it by clicking on the button "Expand All" in the "View" tab of Matlab App Designer.
Or it may be because MATLAB wasn't able to parse the entire .m file. Check out the following link if this is the case: 
If this does not solve the issue, consider contacting MathWorks technical support.
I hope this helps.
  2 comentarios
Val
Val el 24 de Oct. de 2024
Movida: the cyclist el 24 de Oct. de 2024
Clicking the Expand All button resolved my issue. Thank you very much!
Jordi
Jordi el 11 de Jul. de 2025
I had a similar issue with code folding. MATLAB wasn't able to parse the entire .m file because I added comments after line continuations (...). In the code snippet below, for example, comments 1 and 2 may cause the code folding to fail. Removing all text after ... solved the issue for me.
Var = [val_1,... % comment 1
val_2,... % comment 2
val_3]; % comment 3

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by