Browse Source

Code cleanup

Maciej Winnik 1 year ago
parent
commit
78e2fc01c9
1 changed files with 11 additions and 9 deletions
  1. 11 9
      Terminal.Gui/Views/ComboBox.cs

+ 11 - 9
Terminal.Gui/Views/ComboBox.cs

@@ -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>