Skip to content

Commit

Permalink
Do not wrap_visibleVisualLines over _allVisualLines
Browse files Browse the repository at this point in the history
Taking a look to the original avalonedit's textview, when creating the readonlycollection for the _visibleVisualLines it doesn't wrap a collection over the _allVisualLines.

It uses .ToArray() to make the _visibleVisualLines to be a new collection.
  • Loading branch information
danipen committed May 26, 2021
1 parent 0fad77b commit d5c8025
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/AvaloniaEdit/Rendering/TextView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ private void ClearVisualLines()
}
_allVisualLines.Clear();

_visibleVisualLines = new ReadOnlyCollection<VisualLine>(_allVisualLines);
_visibleVisualLines = new ReadOnlyCollection<VisualLine>(_allVisualLines.ToArray());
}
}

Expand Down Expand Up @@ -932,7 +932,7 @@ protected override Size MeasureOverride(Size availableSize)
{
// no document -> create empty list of lines
_allVisualLines = new List<VisualLine>();
_visibleVisualLines = new ReadOnlyCollection<VisualLine>(_allVisualLines);
_visibleVisualLines = new ReadOnlyCollection<VisualLine>(_allVisualLines.ToArray());
maxWidth = 0;
}
else
Expand Down Expand Up @@ -1036,7 +1036,7 @@ private double CreateAndMeasureVisualLines(Size availableSize)

_allVisualLines = _newVisualLines;
// visibleVisualLines = readonly copy of visual lines
_visibleVisualLines = new ReadOnlyCollection<VisualLine>(_newVisualLines);
_visibleVisualLines = new ReadOnlyCollection<VisualLine>(_newVisualLines.ToArray());
_newVisualLines = null;

if (_allVisualLines.Any(line => line.IsDisposed))
Expand Down

0 comments on commit d5c8025

Please sign in to comment.