-
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
Crash when Toggling TextEditor.ShowLineNumbers #434
Comments
OK, I realised there's a simple enough hack for this, where you just have to replace the The below uses a modified version of the AvaloniaEdit/src/AvaloniaEdit/TextEditor.cs Lines 549 to 560 in f92e552
Or something like that, anyway. (Seems to work on my machine!) |
Unless I'm missing something, it seems that changing the
ShowLineNumbers
property of a loadedTextEditor
fromfalse
totrue
will cause anArgumentOutOfRangeException
that seems to be originating fromLineNumberMargin.Render()
. Specifically, this error is occurring in aTextEditor
hosted inside aWindow
which has finished loading and is visible, with theShowLineNumbers
property being changed via user interaction.AvaloniaEdit/src/AvaloniaEdit/Editing/LineNumberMargin.cs
Lines 76 to 80 in f92e552
It seems that the
EmSize
(taken from theTextBlock.FontSizeProperty
) is not being set somehow, possibly because it is set inMeasureOverride()
, which presumably is not being called before rendering?AvaloniaEdit/src/AvaloniaEdit/Editing/LineNumberMargin.cs
Line 55 in f92e552
The "OnChanged" method for
ShowLineNumbers
inTextEditor
creates a brand newLineNumberMargin
Control
when set totrue
fromfalse
, so even if altered in sequencetrue
->false
->true
, the error occurs.Stack trace of error:
If there's a workaround, I'd love to hear about it! So far I have tried:
InvalidateMeasure()
,InvalidateArrange()
andInvalidateVisual()
after changingShowLineNumbers
on theTextEditor
, theTextArea
, and allControl
s intextArea.LeftMargins
; usingDispatcher.UIThread.Invoke()
to change the value ofShowLineNumbers
. None of these have solved the issue.The text was updated successfully, but these errors were encountered: