Sfoglia il codice sorgente

Fixes #3144. TextView Autocomplete does not insert capital letters (#3145)

* Fixes #3144. TextView Autocomplete does not insert capital letters

* Fixes #3144. Fix unit test for fix of TextView Autocomplete does not insert capital letters
joebart457 1 anno fa
parent
commit
3150d43979
2 ha cambiato i file con 4 aggiunte e 4 eliminazioni
  1. 3 3
      Terminal.Gui/Views/TextView.cs
  2. 1 1
      UnitTests/Text/AutocompleteTests.cs

+ 3 - 3
Terminal.Gui/Views/TextView.cs

@@ -3026,14 +3026,14 @@ public class TextView : View {
 	public void InsertText (string toAdd)
 	{
 		foreach (char ch in toAdd) {
-			KeyCode key;
+			Key key;
 			try {
-				key = (KeyCode)ch;
+				key = new Key(ch);
 			} catch (Exception) {
 				throw new ArgumentException ($"Cannot insert character '{ch}' because it does not map to a Key");
 			}
 
-			InsertText (new Key (key));
+			InsertText (key);
 
 			if (NeedsDisplay) {
 				Adjust ();

+ 1 - 1
UnitTests/Text/AutocompleteTests.cs

@@ -153,7 +153,7 @@ namespace Terminal.Gui.TextTests {
 			Assert.Equal (3, g.AllSuggestions.Count);
 			Assert.True (tv.NewKeyDownEvent (new (tv.Autocomplete.SelectionKey)));
 			tv.PositionCursor ();
-			Assert.Equal ($"fortunately Fortunately super feature.", tv.Text);
+			Assert.Equal ($"Fortunately Fortunately super feature.", tv.Text);
 			Assert.Equal (new Point (11, 0), tv.CursorPosition);
 			Assert.Empty (tv.Autocomplete.Suggestions);
 			Assert.Equal (3, g.AllSuggestions.Count);