Quellcode durchsuchen

Fixing some bugs.

BDisp vor 4 Jahren
Ursprung
Commit
bedeca61e6
3 geänderte Dateien mit 10 neuen und 7 gelöschten Zeilen
  1. 1 1
      Terminal.Gui/Core/View.cs
  2. 3 2
      Terminal.Gui/Views/ScrollBarView.cs
  3. 6 4
      UnitTests/ScrollBarViewTests.cs

+ 1 - 1
Terminal.Gui/Core/View.cs

@@ -741,7 +741,7 @@ namespace Terminal.Gui {
 		public void SetChildNeedsDisplay ()
 		public void SetChildNeedsDisplay ()
 		{
 		{
 			ChildNeedsDisplay = true;
 			ChildNeedsDisplay = true;
-			if (container != null && !container.ChildNeedsDisplay)
+			if (container != null)
 				container.SetChildNeedsDisplay ();
 				container.SetChildNeedsDisplay ();
 		}
 		}
 
 

+ 3 - 2
Terminal.Gui/Views/ScrollBarView.cs

@@ -448,7 +448,7 @@ namespace Terminal.Gui {
 				return false;
 				return false;
 			}
 			}
 
 
-			if (!Host.HasFocus) {
+			if (Host != null && !Host.HasFocus) {
 				Host.SetFocus ();
 				Host.SetFocus ();
 			}
 			}
 
 
@@ -537,7 +537,8 @@ namespace Terminal.Gui {
 		internal bool CanScroll (int n, out int max, bool isVertical = false)
 		internal bool CanScroll (int n, out int max, bool isVertical = false)
 		{
 		{
 			if (Host == null) {
 			if (Host == null) {
-				throw new ArgumentNullException ("The host can't be null.");
+				max = 0;
+				return false;
 			}
 			}
 			var s = isVertical ?
 			var s = isVertical ?
 				(KeepContentAlwaysInViewport ? Host.Bounds.Height + (showBothScrollIndicator ? -2 : -1) : 0) :
 				(KeepContentAlwaysInViewport ? Host.Bounds.Height + (showBothScrollIndicator ? -2 : -1) : 0) :

+ 6 - 4
UnitTests/ScrollBarViewTests.cs

@@ -118,11 +118,13 @@ namespace Terminal.Gui {
 		}
 		}
 
 
 		[Fact]
 		[Fact]
-		public void Scrolling_With_Default_Constructor_Throws_ArgumentNullException ()
+		public void Scrolling_With_Default_Constructor_Do_Not_Scroll ()
 		{
 		{
-			var sbv = new ScrollBarView ();
-
-			Assert.Throws<ArgumentNullException> ("The host can't be null.", () => sbv.Position = 1);
+			var sbv = new ScrollBarView {
+				Position = 1
+			};
+			Assert.NotEqual (1, sbv.Position);
+			Assert.Equal (0, sbv.Position);
 		}
 		}
 
 
 		[Fact]
 		[Fact]