Fixing some bugs.

This commit is contained in:
BDisp
2021-01-15 23:04:49 +00:00
parent b3817d8ff1
commit bedeca61e6
3 changed files with 10 additions and 7 deletions

View File

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

View File

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

View File

@@ -118,11 +118,13 @@ namespace Terminal.Gui {
}
[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]