Line numbers (margin) misaligned with the editor
For some reason the line numbers are misaligned with the editor (see picture below):
Here's my AXAML:
<avaloniaEdit:TextEditor SyntaxHighlighting="{Binding SyntaxTheme}" ShowLineNumbers="True" FontFamily="Consolas">
<avaloniaEdit:TextEditor.Options>
<avaloniaEdit:TextEditorOptions IndentationSize="3" ConvertTabsToSpaces="True" HighlightCurrentLine="False" />
</avaloniaEdit:TextEditor.Options>
<avaloniaEdit:TextEditor.Styles>
<Style Selector="editing|LineNumberMargin">
<Setter Property="MinWidthInDigits" Value="4" />
</Style>
</avaloniaEdit:TextEditor.Styles>
</avaloniaEdit:TextEditor>
This happens whether setting the FontFamily or not. I'm using <FluentTheme /> only (no other styles).
Bonus: is there a way to add a margin on the sides of the line numbers border?
The text alignment looks fine on my machine (AvaloniaEdit 11.2, Windows 11, no dpi scaling).
Can you reproduce the problem in the AvaloniaEdit.Demo? What is your OS version and AvaloniaEdit version?
Bonus: is there a way to add a margin on the sides of the line numbers border?
You can change the TextView style to add a margin between the line numbers and the text. See example here: https://github.com/AvaloniaUI/AvaloniaEdit/issues/477#issuecomment-2763238576
My bet is that this is a similar issue to my fixes in the following PR. It's going to be important that the line number font and such is exactly the same as the text view.
https://github.com/AvaloniaUI/AvaloniaEdit/pull/519