ScrollToEnd does not scroll to end when using WordWrap #226
Labels
No labels
Area-Accessibility
Area-Build
Area-CodeCompletion
Area-Document
Area-Documentation
Area-Editing
Area-Folding
Area-Highlighting
Area-i18n
Area-Indentation
Area-NetFx
Area-Rendering
Area-Search
Area-Snippets
dependencies
duplicate
Feedback Needed
help wanted
invalid
Issue-Bug
Issue-Discussion
Issue-Enhancement
Issue-Performance
Issue-Question
on-hold
Resolution-Answered
Resolution-By Design
Resolution-Duplicate
Resolution-Fixed
Resolution-Won't Fix
Up-for-Grabs
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-icsharpcode/AvalonEdit#226
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
My AvalonEdit has to show the content of a log file. Changes to the log file will be attached automatically with AppendText(). Afterwards the editor should scroll to the end of the document. But it does not. A few lines (the ones after the selected one) are (almost) always missing. See screenshot:

XAML:
Some code:
I've also tried ScrollToLine() and ScrollToVerticalOffset() but the result stays the same.
The only thing which solves my issue (but is not an option for me) is to set WordWrap to false.
Any suggestions?
Best regards,
Carsten
I have this issue currently as well (ScrollToEnd works for me but is really slow, I'm using ScrollToVerticalOffset). To elaborate, does this happen when you have lines wrapped (e.g. is the line wrapping causing the issue, that's what triggers the issue for me and I need to leave line wrapping on myself)?
As mentioned before:
So, yes: Word wrapping causes my issue.
See if this words. I had it in an inherited class but you get the idea. It seems to perform as well as ScrollToVerticalOffset and also takes it all the way to the bottom (including wraps). I haven't tested it extensively but I'm going to.
Doesn't work for me. Or let's say: It does not work if there are wrapped lines in the view. If there are only "not wrapped" lines in the view, everything's fine.
I just saw the the search has the same issue: The found result may be out of the view if there are wrapped lines in the view. So you have to scroll a view lines to see the result.
Apparantly I spoke too quickly. The scroll to still seems inefficient when I profile my app. I finally figured out how to determine if a line is wrapped though (and then can use the vertical offset approach when the last line isn't wrapped). I inherited from the editor.
However, an issue still exists with this where the VisualLines are sometimes not valid when requested. If
EnsureVisualLines()is called the collection has 0 items. So. :/ I guess I'm still trying to refine this to get a reliable way to check for wrapping on the visible part of the screen.I solved it by calling ScrollToEnd twice.
Here's where I finally fell. I set a bool property on whether anything is wrapped during the
VisualLineChangedevent. Since my logger is constantly scrolling to the bottom it was pretty accurate for me (even if it ran before the lines updated). I was able to determine which way to scroll then. In the chance that the VisualLinesValid came backfalseI left theHasVisibleWrappedproperty in it's previous state. This was acceptable for my use case, I can see why it wouldn't be for others.My event looked something like this:
Edit: I updated this to use
VisualLineChangedinstead ofVisualLinesChangingand also to use theDependentLengthproperty instead ofTextLines.Count > 0.I was desperate enough to give it a try but it did not work for me.
So now you have
HasVisibleWrappedLineseithertrueorfalse. What are you doing in either case to scroll to the very bottom? I have triedScrollToVerticalOffset(),ScrollToEnd()in various combinations without any success, I do not really see how this new variable should help.This is what I'm using in my mud client:
ScrollToVerticalOffsetalways works for me IF there are no wrapped lines (it uses significantly less CPU when profiled). Whatever works for you that's that's fool proof (but less efficient) can go into the top part of the if. I've been testing with this for 4-5 days now and I haven't had any issues. I'm going to make a release for my testers and see how that goes when it's in the wild.Workaround here: