How to comment all lines in folded code

Hi,

I’m using CodeMirror v6 and I’m having a problem with commenting folded code.

If the code is folded and the cursor is on the first line of the code, when I use CMD + / to add a comment, it only adds a comment to the last line of the folded code. I can see this when I expand the code.

image
image
image

The expected IDE behaviour for adding comments to folded code is for every single line in the fold to have a comment.

I can achieve this only if I highlight the folded code first, but this is not the expected behaviour.

I’ve read countless things online about possibly using a custom extension or mode to do this, but I don’t know where to start.

Could anyone please point me in the right direction?

Thanks,
Josh

Select the folded range if you want to comment all of it. When there’s just a cursor, commenting will comment out only the line with the cursor.

Hi @marijn,

Thanks for that. I know you can achieve the desired result by highlighting the whole line. However, that’s not the standard behaviour of most IDEs. I’m trying to achieve the same result by simply having the cursor on the first line while the code is folded.

Thanks,
Josh