瀏覽代碼

Only render tabs if layout is needed.

BDisp 8 月之前
父節點
當前提交
6cb8478b6e
共有 2 個文件被更改,包括 11 次插入6 次删除
  1. 6 6
      Terminal.Gui/Views/TabView/TabRowView.cs
  2. 5 0
      Terminal.Gui/Views/TabView/TabView.cs

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

@@ -86,15 +86,12 @@ internal class TabRowView : View
             {
             {
                 _host.SwitchTabBy (scrollIndicatorHit);
                 _host.SwitchTabBy (scrollIndicatorHit);
 
 
-                SetNeedsLayout ();
-
                 return true;
                 return true;
             }
             }
 
 
             if (hit is { })
             if (hit is { })
             {
             {
                 _host.SelectedTab = hit;
                 _host.SelectedTab = hit;
-                SetNeedsLayout ();
 
 
                 return true;
                 return true;
             }
             }
@@ -119,11 +116,14 @@ internal class TabRowView : View
     /// <inheritdoc />
     /// <inheritdoc />
     protected override void OnSubviewLayout (LayoutEventArgs args)
     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);
         base.OnSubviewLayout (args);
     }
     }

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

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