Code cleanup

This commit is contained in:
Maciej Winnik
2023-08-19 13:13:29 +02:00
parent c542b81135
commit 78e2fc01c9

View File

@@ -39,10 +39,7 @@ namespace Terminal.Gui {
private void Initialize (ComboBox container, bool hideDropdownListOnClick)
{
if (container == null)
throw new ArgumentNullException ("ComboBox container cannot be null.", nameof (container));
this.container = container;
this.container = container ?? throw new ArgumentNullException ("ComboBox container cannot be null.", nameof (container));
HideDropdownListOnClick = hideDropdownListOnClick;
}
@@ -236,7 +233,7 @@ namespace Terminal.Gui {
readonly TextField search;
readonly ComboListView listview;
bool autoHide = true;
int minimumHeight = 2;
readonly int minimumHeight = 2;
/// <summary>
/// Public constructor
@@ -721,7 +718,7 @@ namespace Terminal.Gui {
return text;
}
set {
search.Text = text = value;
SetSearchText (value);
}
}
@@ -733,7 +730,7 @@ namespace Terminal.Gui {
return search.Text;
}
set {
search.Text = text = value;
SetSearchText (value);
}
}
@@ -787,7 +784,7 @@ namespace Terminal.Gui {
private void Reset (bool keepSearchText = false)
{
if (!keepSearchText) {
search.Text = text = "";
SetSearchText (string.Empty);
}
ResetSearchSet ();
@@ -800,6 +797,11 @@ namespace Terminal.Gui {
}
}
private void SetSearchText (ustring value)
{
search.Text = text = value;
}
private void ResetSearchSet (bool noCopy = false)
{
searchset.Clear ();
@@ -855,7 +857,7 @@ namespace Terminal.Gui {
listview.SetSource (searchset);
listview.Clear (); // Ensure list shrinks in Dialog as you type
listview.Height = CalculatetHeight ();
this.SuperView?.BringSubviewToFront (this);
SuperView?.BringSubviewToFront (this);
}
/// <summary>