Closed JeffryBooher closed 10 years ago
Thanks that an interesting one - and very easy to reproduce. It is easy to see how the undo changes the state of the folding regions - and this issue goes right down into the code-mirror addon for folding. So, from a user point of view perhaps it make sense to automatically unfold folded regions that no longer exist? i.e., when you do an undo or delete the char that closes a fold region, if the region is folded, then it should be expanded.
That's what i was thinking as well but you could also ague that the outer /* */ is invalid and shouldn't be collapsible. Not sure if that solves the issue or not but something to think about.
Indeed because the concept of nesting is ubiquitous. e.g., nested functions, JS object literals etc. So it is even reproducible using:
function () {
function() {
}}
Collapse the outermost function and delete the last brace.
For now I have a fix that auto expands the invalid
range. I will push once I'm reasonably convinced it doesnt break anything else.
3 . now wrap the block with
/* */
You should end up with something like this:
4 . collapse the block 5 . undo
While trying to find the steps to this I was occasionally unable to reproduce this but i did get it to reproduce if I added the closing
*/
first then the opening comment/*
, collapsed then undo so you might want to try it both ways.