Skip to content
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

Setting SelectionForegroundBrush for TextBox kills performance #17054

Open
HermanKirshin opened this issue Sep 18, 2024 · 0 comments
Open

Setting SelectionForegroundBrush for TextBox kills performance #17054

HermanKirshin opened this issue Sep 18, 2024 · 0 comments
Labels

Comments

@HermanKirshin
Copy link
Contributor

Describe the bug

Selection in TextBox becomes too slow with large amount of text

TextPresenter.CreateTextLayout has condition that initializes textStyleOverrides when SelectionForegroundBrush is not null

if (length > 0 && SelectionForegroundBrush != null)

And in case FormattedTextSource.CreateTextStyleRun receives non-empty collection in textModifier parameter it executes main part of method's body which works slowly with big amounts of text.
if (textModifier == null || textModifier.Count == 0)

To Reproduce

Create simple multiline TextBox and set SelectionForegroundBrush to any value.
<TextBox Name="TextBox" AcceptsReturn="True" SelectionForegroundBrush="Blue" />
And fill it with a quite large amount of text (200kb).
Try to select anything - selection works with freezes.

Expected behavior

No response

Avalonia version

11.1.3

OS

No response

Additional context

sample_text.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant