Prechádzať zdrojové kódy

Only render tabs if layout is needed.

BDisp 8 mesiacov pred
rodič
commit
6cb8478b6e

+ 6 - 6
Terminal.Gui/Views/TabView/TabRowView.cs

@@ -86,15 +86,12 @@ internal class TabRowView : View
             {
                 _host.SwitchTabBy (scrollIndicatorHit);
 
-                SetNeedsLayout ();
-
                 return true;
             }
 
             if (hit is { })
             {
                 _host.SelectedTab = hit;
-                SetNeedsLayout ();
 
                 return true;
             }
@@ -119,11 +116,14 @@ internal class TabRowView : View
     /// <inheritdoc />
     protected override void OnSubviewLayout (LayoutEventArgs args)
     {
-        _host._tabLocations = _host.CalculateViewport (Viewport).ToArray ();
+        if (NeedsLayout)
+        {
+            _host._tabLocations = _host.CalculateViewport (Viewport).ToArray ();
 
-        RenderTabLine ();
+            RenderTabLine ();
 
-        RenderUnderline ();
+            RenderUnderline ();
+        }
 
         base.OnSubviewLayout (args);
     }

+ 5 - 0
Terminal.Gui/Views/TabView/TabView.cs

@@ -109,6 +109,11 @@ public class TabView : View
         get => _selectedTab;
         set
         {
+            if (value == _selectedTab)
+            {
+                return;
+            }
+
             Tab? old = _selectedTab;
             _selectedTabHasFocus = old is { } && (old.HasFocus || !_containerView.CanFocus);