Browse Source

Merge pull request #1437 from tznind/fix-auto

Fixed bug setting ColorScheme on Autocomplete
Charlie Kindel 3 years ago
parent
commit
e3f6b7b283
2 changed files with 29 additions and 1 deletions
  1. 1 1
      Terminal.Gui/Core/Autocomplete.cs
  2. 28 0
      UnitTests/AutocompleteTests.cs

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

@@ -67,7 +67,7 @@ namespace Terminal.Gui {
 			}
 			}
 		 	set
 		 	set
 			{
 			{
-				ColorScheme = value;
+				colorScheme = value;
 			}
 			}
 		}
 		}
 
 

+ 28 - 0
UnitTests/AutocompleteTests.cs

@@ -25,5 +25,33 @@ namespace UnitTests {
 			Assert.Equal ("Cobble", ac.Suggestions[1]);
 			Assert.Equal ("Cobble", ac.Suggestions[1]);
 
 
 		}
 		}
+
+		[Fact]
+		[AutoInitShutdown]
+		public void TestSettingColorSchemeOnAutocomplete ()
+		{
+			var tv = new TextView ();
+
+			// to begin with we should be using the default menu color scheme
+			Assert.Same (Colors.Menu, tv.Autocomplete.ColorScheme);
+
+			// allocate a new custom scheme
+			tv.Autocomplete.ColorScheme = new ColorScheme () {
+				Normal = Application.Driver.MakeAttribute (Color.Black, Color.Blue),
+				Focus = Application.Driver.MakeAttribute (Color.Black, Color.Cyan),
+			};
+
+			// should be seperate instance
+			Assert.NotSame (Colors.Menu, tv.Autocomplete.ColorScheme);
+
+			// with the values we set on it
+			Assert.Equal (Color.Black, tv.Autocomplete.ColorScheme.Normal.Foreground);
+			Assert.Equal (Color.Blue, tv.Autocomplete.ColorScheme.Normal.Background);
+
+			Assert.Equal (Color.Black, tv.Autocomplete.ColorScheme.Focus.Foreground);
+			Assert.Equal (Color.Cyan, tv.Autocomplete.ColorScheme.Focus.Background);
+
+
+		}
 	}
 	}
 }
 }