소스 검색

Fixes #3122. Shift-Tab is broken on TextView. (#3123)

BDisp 1 년 전
부모
커밋
e2a59050fe
3개의 변경된 파일23개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      Terminal.Gui/ConsoleDrivers/WindowsDriver.cs
  2. 5 0
      Terminal.Gui/Views/TextView.cs
  3. 16 0
      UnitTests/Views/TextViewTests.cs

+ 2 - 0
Terminal.Gui/ConsoleDrivers/WindowsDriver.cs

@@ -1061,6 +1061,8 @@ internal class WindowsDriver : ConsoleDriver {
 
 			if (keyInfo.KeyChar == 0) {
 				return MapToKeyCodeModifiers (keyInfo.Modifiers, (KeyCode)(keyInfo.KeyChar));
+			} else if (keyInfo.Key != ConsoleKey.None) {
+				return MapToKeyCodeModifiers (keyInfo.Modifiers, (KeyCode)(keyInfo.KeyChar));
 			} else {
 				return MapToKeyCodeModifiers (keyInfo.Modifiers & ~ConsoleModifiers.Shift, (KeyCode)(keyInfo.KeyChar));
 			}

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

@@ -3373,6 +3373,9 @@ public class TextView : View {
 	///<inheritdoc/>
 	public override bool? OnInvokingKeyBindings (Key a)
 	{
+		if (!a.IsValid) {
+			return false;
+		}
 		// Give autocomplete first opportunity to respond to key presses
 		if (SelectedLength == 0 && Autocomplete.Suggestions.Count > 0 && Autocomplete.ProcessKey (a)) {
 			return true;
@@ -3753,6 +3756,8 @@ public class TextView : View {
 					HistoryText.LineStatus.Replaced);
 			}
 
+			SetNeedsDisplay ();
+
 			UpdateWrapModel ();
 		}
 		DoNeededAction ();

+ 16 - 0
UnitTests/Views/TextViewTests.cs

@@ -1541,6 +1541,9 @@ public class TextViewTests {
 	[TextViewTestsAutoInitShutdown]
 	public void TabWidth_Setting_To_Zero_Keeps_AllowsTab ()
 	{
+		Application.Top.Add (_textView);
+		Application.Begin (Application.Top);
+
 		Assert.Equal (4, _textView.TabWidth);
 		Assert.True (_textView.AllowsTab);
 		Assert.True (_textView.AllowsReturn);
@@ -1552,8 +1555,21 @@ public class TextViewTests {
 		Assert.True (_textView.Multiline);
 		_textView.NewKeyDownEvent (new (KeyCode.Tab));
 		Assert.Equal ("\tTAB to jump between text fields.", _textView.Text);
+		Application.Refresh ();
+		TestHelpers.AssertDriverContentsWithFrameAre (@"
+TAB to jump between text field", _output);
+
+		_textView.TabWidth = 4;
+		Application.Refresh ();
+		TestHelpers.AssertDriverContentsWithFrameAre (@"
+    TAB to jump between text f", _output);
+
 		_textView.NewKeyDownEvent (new (KeyCode.Tab | KeyCode.ShiftMask));
 		Assert.Equal ("TAB to jump between text fields.", _textView.Text);
+		Assert.True (_textView.NeedsDisplay);
+		Application.Refresh ();
+		TestHelpers.AssertDriverContentsWithFrameAre (@"
+TAB to jump between text field", _output);
 	}
 
 	[Fact]