marcelwgn / IndentRainbow

Visual Studio extension for colorization of indent levels
https://marketplace.visualstudio.com/items?itemName=chingucoding.IndentRainbow
MIT License
32 stars 8 forks source link

remove gap between indent lines #28

Closed ta5n closed 1 year ago

ta5n commented 1 year ago

Hi @chingucoding, thank you for such a useful extension. I'd like to remove the gap between lines of indentation as seen in the image. On the left side IndentRainbow extension, and on the right vscode indent-rainbow of same code piece. I've tried to change the file, src\IndentRainbow.Extension\Drawing\BackgroundTextIndexDrawer.cs line:#29 as below: Geometry geometry = view.TextViewLines.GetMarkerGeometry(span, false, new Thickness( 0, view.LineHeight / 2, 0, view.LineHeight / 2));

Unfortunately it made indentguides larger than expected and overlapped with other. Would you give some clue to get line-spacing value and set thickness properly?

Thanks in advance

indent_guides

marcelwgn commented 1 year ago

Hi @ta5n, thank you for your issue! Can you share your Visual Studio Settings so I can debug the issue better? For me, the background colors are rendering flush so it would be good to know what settings I need to change to help debug this better.

ta5n commented 1 year ago

Sure, here below exported settings. Imho, if I can grab line spacing setting and calculate upper and lower bounds of lines accordingly, it seems indentrainbows will be continious. Btw here below my color codes:(just semi-transparent gray-white gradient) `#07918e92,#0c918e92,#11918e92,#16918e92,#1b918e92,#20918e92,#25918e92 error-color

99802020`

Best regards Exported-2022-11-04.zip image

marcelwgn commented 1 year ago

I think something along these lines would be more accurate:

Geometry geometry = view.TextViewLines.GetMarkerGeometry(span, false, new Thickness(0, 0, 0,  view.LineHeight - view.TextViewLines.WpfTextViewLines[0].TextHeight)); 

The issue seems to be that the actual line height is not taken into account when calculating the spans dimension.

Alternatively, something like this could work but there still are small gaps:

var newRect = new Rect()
{
    X = geometry.Bounds.X,
    Y = geometry.Bounds.Y,
    Width = geometry.Bounds.Width,
    Height = view.LineHeight
};
var copiedGeometry = new RectangleGeometry(newRect);
var drawing = new GeometryDrawing(drawBrush, null, copiedGeometry);
ta5n commented 1 year ago

Thanks it worked! image

ta5n commented 1 year ago

side by side comparison with vscode extension

image

marcelwgn commented 1 year ago

Awesome! Would you like to create a pull request so this fix is available for everyone?

ta5n commented 1 year ago

Awesome! Would you like to create a pull request so this fix is available for everyone?

sure but, actually you wrote the solution, it is not my own contribution, therefore I thought that this minor fix fully belongs to you. I've just applied your code to my local copy, and it worked as charm. If it is OK for you, I'll happily create a PR. thanks for your modesty. regards

marcelwgn commented 1 year ago

The fix is now available in version 1,2,3, thank you for mentioning this issue and creating the PR!