leodevbro / vscode-blockman

VSCode extension to highlight nested code blocks
https://github.com/leodevbro/vscode-blockman
MIT License
345 stars 16 forks source link

N04 Sub05 adds extra whitespace to end of line inside inner block #69

Open kc9jud opened 2 years ago

kc9jud commented 2 years ago

I noticed that the new option for adding padding on the right also introduces a significant amount of padding inside the inner-most block.

Code:

# hello
for i in range(10):
    for j in range(20):
        print("Hello world, from ({},{})".format(i,j))
        # expand block
        count += 1

N04 Sub05 -> 0: image

N04 Sub05 -> 4: image

I think it might be interacting poorly with N24: image image image

leodevbro commented 2 years ago

That's because the calculation formula for N04 Sub05 is like this:

rightPaddingIncrement = (maxDepth - currDepth) * minDistanceBetweenRightEdges

It is a fast formula, performance is more optimized with it. If we want more precise formula, then I guess we need to make much more complex and CPU heavy calculations. I think current formula is good enough. I hope it's ok for you.

You mentioned N24, and yeah, it will make some effect on the formula because if you enable round brackets and maybe also square brackets, it means you are creating more blocks. More blocks often means some changes in depth indexes, so it will effect the formula.