Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/UniGetUI.Avalonia/Views/Controls/LogTextEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public void ClearLines()

public void ScrollToBottom() => ScrollToEnd();

// True when the view is pinned to the last line; used to keep auto-scroll from fighting a manual scroll-up.
public bool IsScrolledToBottom => ExtentHeight - ViewportHeight - VerticalOffset <= 1.0;

// AvaloniaEdit auto-links URLs; its default link brush is too dark to read on the dark theme.
private void UpdateLinkColor()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private void OnOutputLinesChanged(object? sender, NotifyCollectionChangedEventAr
{
Dispatcher.UIThread.Post(() =>
{
bool wasAtBottom = OutputText.IsScrolledToBottom;
if (e.Action == NotifyCollectionChangedAction.Reset)
{
OutputText.ClearLines();
Expand All @@ -33,7 +34,9 @@ private void OnOutputLinesChanged(object? sender, NotifyCollectionChangedEventAr
foreach (LogLineItem item in e.NewItems)
OutputText.AppendLine(item);
}
OutputText.ScrollToBottom();
// Only follow new output if the user hadn't scrolled up to read earlier lines.
if (wasAtBottom)
OutputText.ScrollToBottom();
}, DispatcherPriority.Background);
}

Expand Down
Loading