Sublime Forum

Code folding not working with JS files

#1

I’m on v4143 on a Mac and having issues with code folding on javascript files. Not tried any other languages yet.

Problem seems to manifest in larger test files where I have many nested functions (Jest describe blocks with lots of test blocks inside). When I fold a function it’s often folding multiple functions and the only way to fix it I have found is to unfold every function.

Anyone else having this issue?

0 Likes

#2

How do you fold those functions?

If you happen to use “fold by level” it does no longer fold a block a caret is located within, but would fold all its nested blocks.

0 Likes

#3

I am folding using the triangle symbols next to the line numbers. I have not found a reliable way to repeat the issue, was just wondering if anyone else is having a problem with it. If I can figure out what action is causing it I can maybe post a short video of the issue.

0 Likes

#4

I’ve still not got a reliable way to reproduce this issue, but I have been able to grab a few screenshots to show you the problem.

Here is the first screenshot:

This looks normal but in fact the function on line 628 is inside a completely different describe block that has become hidden when I tried to hide the function above it (function is on line 582).

0 Likes

#5

To fix this I tried closing the previous describe block on line 475 and got the following:

You can see that I’ve collapsed the function because the arrow is now pointing horizontal, but only the first function inside it has disappeared, the remaining functions are still visible.

0 Likes

#6

In the end I had to expand and then collapse all the functions to return it to how it should be, see this pic:

Notice the original describe block on line 627 that had disappeared in the original screenshot.

0 Likes

#7

I’m now on build 4152 and still having major issues with code folding. I’ve only seen it happening in large javascript files but I believe that’s most likely because I don’t really use code folding in smaller files.

Still not found a reliable way to reproduce the issue, code folding seems to be working well, then randomly I will scroll the page and find that it’s corrupted. Here is a screenshot:

As previously, the yellow code folding blocks (…) are appearing randomly halfway through lines.

Since I last reported this issue I’m now working on a new machine, fresh install of Sublime 4 on Mac OS 14 and have Terminus and Prettier plugins installed.

0 Likes

#8

I’ve managed to reliably recreate the issue on my machine. If I fold a block of code, then go to another block of code and create a new blank line inside the block and save the file the code folding corrupts itself. The new line is also removed by jsPrettier.

So I think this is a problem related to jsPrettier. If I disable this plugin the code folding appears to be working correctly.

1 Like

#9

There’s a new plugin called prettierd. Though jsprettier has more features, I don’t like it blocking the app when saving. It is a bit clunky for me.

0 Likes

#10

Thanks, that’s a great point. I’ve installed prettierd and it seems to be working very well.

1 Like