CodeblockCustomizer icon indicating copy to clipboard operation
CodeblockCustomizer copied to clipboard

Semi fold does not show code for blocks with less than X lines

Open notDavid opened this issue 3 months ago • 7 comments

Hi there, the issue i'm seeing is:

  1. Enable Inverse Fold behavior
  2. Enable Enable semi-fold (only the first checkbox of the two)
  3. Set number of Enable semi-fold lines to 5
  4. Create a code block with only 3 lines of code
  5. Observer that all the code is collapsed and nothing is visible

I would expect to see the 3 lines ?

Please advise :-) Thank you!

screenshot preview... Image
screenshot edit... Image
screenshot settings... Image

notDavid avatar Oct 05 '25 14:10 notDavid

It is actually correct :) Look here: https://github.com/mugiwara85/CodeblockCustomizer?tab=readme-ov-file#semi-fold If you set the visible lines to 3, then your code block must have at lesat 3 + 4 lines. The 4 lines is basically the fade-out effect. So your code blocks are fully collapsed because they do not meet the criteria to be able to semi-folded.

mugiwara85 avatar Oct 05 '25 14:10 mugiwara85

Thank you for clarifying @mugiwara85 , okay i see;

Wouldn't it make more sense to unfold (show all lines) in these cases, instead of fold (showing 0 lines) ?

Because basically now it means that the first lines of these very short code snippets can never be shown. So I'd have to manually unfold every single one to at least see something...?

notDavid avatar Oct 05 '25 16:10 notDavid

Well, yes and no. So the basic folding is just hiding all lines. Semi-folding is basically just an addition to that so you can display the last 4 line "fading out". If a code block can't be semi-folded, but you either specified "fold", or "inverse fold", than this means that the code block should be folded. But since it doesnt meet the requirements it is being folded normally. I could add an option something like "Do not fold code block if it does not meet semi-fold requirements". When this would be enabled, your 3 line code block would not be folded at all. Would this be ok for you?

mugiwara85 avatar Oct 05 '25 16:10 mugiwara85

Great, sounds perfect. Thank you!

PS. the link to "Contributing & Support" in the readme does not work 😉

https://github.com/mugiwara85/CodeblockCustomizer#contributing--support should be: https://github.com/mugiwara85/CodeblockCustomizer#contributing-support

notDavid avatar Oct 05 '25 17:10 notDavid

Ok, I will implement this before the next release. Shouldn't be a big deal.

Thanks, I probably just mistyped it. I fixed it!

mugiwara85 avatar Oct 05 '25 17:10 mugiwara85

@notDavid I added the option. It is under Folding Settings, and is called "Only apply inverse fold to semi-foldable blocks". It is only visible, when inverse fold, and semi-fold are both enabled. If you want to test it, jsut take the current main.js and styles.css and overwrite yours with it.

mugiwara85 avatar Oct 12 '25 23:10 mugiwara85

Hi @mugiwara85 , great it seems to be working 👌🏼

Thank you for the quick solution!

notDavid avatar Oct 13 '25 07:10 notDavid