-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tab Column Misalignment #412
Comments
I have found a temporary workaround for the bug until it is fixed.
_textEditor.Options.IndentationSize = 1;
_textEditor.Options.ShowTabs = true;
Change TabTextElement class from private to internal. internal sealed class TabTextElement : VisualLineElemen
{
public int TabSize = 0;
...
} Fix Size override of TabGlyphRun. private sealed class TabGlyphRun : DrawableTextRun
{
...
//public override Size Size => default;
public override Size Size
{
get
{
return new Size(_element.Text.WidthIncludingTrailingWhitespace* (_element.TabSize-1), 0);
}
}
...
}
private void CalculateOffsets()
{
var visualOffset = 0;
var textOffset = 0;
int tabOffset= 0;
foreach (var element in _elements)
{
element.VisualColumn = visualOffset;
element.RelativeTextOffset = textOffset;
visualOffset += element.VisualLength;
textOffset += element.DocumentLength;
if(element is SingleCharacterElementGenerator.TabTextElement)
{
(element as SingleCharacterElementGenerator.TabTextElement).TabSize = 4-(tabOffset%4);
tabOffset = 0;
}
else
{
tabOffset = tabOffset + element.DocumentLength;
}
}
VisualLength = visualOffset;
Debug.Assert(textOffset == LastDocumentLine.EndOffset - FirstDocumentLine.Offset);
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When inserting characters before a tab, the tab’s column position does not align as expected.
The expected behavior was as shown in the image below.
AvaloniaEdit 11.0.6 + .net 6.0 + Windows 11 Home
The text was updated successfully, but these errors were encountered: