Pārlūkot izejas kodu

Fix of issue #1448
InvalidateFormattedText was doing mainly 2 activities, resets formatted text and resets measure.
Splited it and extracted reset of formatted text in to seprate function and using it over there.

TextPresenter usis obervable stream for SelectionStart/End property, over there inside subscriber instead of calling InvalidateFormatedText now we use only ClearFormatedText.

The reason is SelectionStart/End is not going to make any changes regarding measurement and hence reseting formatted text alone is sufficient enough

achal7 7 gadi atpakaļ
vecāks
revīzija
802729bd2d

+ 1 - 1
src/Avalonia.Controls/Presenters/TextPresenter.cs

@@ -43,7 +43,7 @@ namespace Avalonia.Controls.Presenters
             Observable.Merge(
                 this.GetObservable(SelectionStartProperty),
                 this.GetObservable(SelectionEndProperty))
-                .Subscribe(_ => InvalidateFormattedText());
+                .Subscribe(_ => ClearFormattedText());
 
             this.GetObservable(CaretIndexProperty)
                 .Subscribe(CaretIndexChanged);

+ 9 - 2
src/Avalonia.Controls/TextBlock.cs

@@ -364,14 +364,21 @@ namespace Avalonia.Controls
         /// Invalidates <see cref="FormattedText"/>.
         /// </summary>
         protected void InvalidateFormattedText()
+        {
+            ClearFormattedText();
+            InvalidateMeasure();
+        }
+
+        /// <summary>
+        /// Invalidates <see cref="FormattedText"/>.
+        /// </summary>
+        protected void ClearFormattedText()
         {
             if (_formattedText != null)
             {
                 _constraint = _formattedText.Constraint;
                 _formattedText = null;
             }
-
-            InvalidateMeasure();
         }
 
         /// <summary>