瀏覽代碼

Fixed TextView not handling space

Tig 9 月之前
父節點
當前提交
5006e0036b
共有 2 個文件被更改,包括 15 次插入0 次删除
  1. 2 0
      Terminal.Gui/Views/TextView.cs
  2. 13 0
      UnitTests/Views/TextViewTests.cs

+ 2 - 0
Terminal.Gui/Views/TextView.cs

@@ -2406,6 +2406,8 @@ public class TextView : View
                     }
                    );
 
+        KeyBindings.Remove (Key.Space);
+
         KeyBindings.Remove (Key.Enter);
         KeyBindings.Add (Key.Enter, Multiline ? Command.NewLine : Command.Accept);
 

+ 13 - 0
UnitTests/Views/TextViewTests.cs

@@ -8534,6 +8534,19 @@ line.
         void Accept (object sender, CommandEventArgs e) { accepted++; }
     }
 
+
+    [Fact]
+    public void Space_Key_Types_Space ()
+    {
+        var view = new TextView ()
+        {
+        };
+
+        view.NewKeyDownEvent (Key.Space);
+
+        Assert.Equal (" ", view.Text);
+    }
+
     [Theory]
     [InlineData (false, false, 1, 1)]
     [InlineData (false, true, 1, 0)]