Skip to content

Commit e2a5905

Browse files
authored
Fixes #3122. Shift-Tab is broken on TextView. (#3123)
1 parent 0484fc8 commit e2a5905

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

Terminal.Gui/ConsoleDrivers/WindowsDriver.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,8 @@ KeyCode MapKey (WindowsConsole.ConsoleKeyInfoEx keyInfoEx)
10611061

10621062
if (keyInfo.KeyChar == 0) {
10631063
return MapToKeyCodeModifiers (keyInfo.Modifiers, (KeyCode)(keyInfo.KeyChar));
1064+
} else if (keyInfo.Key != ConsoleKey.None) {
1065+
return MapToKeyCodeModifiers (keyInfo.Modifiers, (KeyCode)(keyInfo.KeyChar));
10641066
} else {
10651067
return MapToKeyCodeModifiers (keyInfo.Modifiers & ~ConsoleModifiers.Shift, (KeyCode)(keyInfo.KeyChar));
10661068
}

Terminal.Gui/Views/TextView.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3373,6 +3373,9 @@ public void ScrollTo (int idx, bool isRow = true)
33733373
///<inheritdoc/>
33743374
public override bool? OnInvokingKeyBindings (Key a)
33753375
{
3376+
if (!a.IsValid) {
3377+
return false;
3378+
}
33763379
// Give autocomplete first opportunity to respond to key presses
33773380
if (SelectedLength == 0 && Autocomplete.Suggestions.Count > 0 && Autocomplete.ProcessKey (a)) {
33783381
return true;
@@ -3753,6 +3756,8 @@ bool ProcessBackTab ()
37533756
HistoryText.LineStatus.Replaced);
37543757
}
37553758

3759+
SetNeedsDisplay ();
3760+
37563761
UpdateWrapModel ();
37573762
}
37583763
DoNeededAction ();

UnitTests/Views/TextViewTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,9 @@ public void Copy_Without_Selection ()
15411541
[TextViewTestsAutoInitShutdown]
15421542
public void TabWidth_Setting_To_Zero_Keeps_AllowsTab ()
15431543
{
1544+
Application.Top.Add (_textView);
1545+
Application.Begin (Application.Top);
1546+
15441547
Assert.Equal (4, _textView.TabWidth);
15451548
Assert.True (_textView.AllowsTab);
15461549
Assert.True (_textView.AllowsReturn);
@@ -1552,8 +1555,21 @@ public void TabWidth_Setting_To_Zero_Keeps_AllowsTab ()
15521555
Assert.True (_textView.Multiline);
15531556
_textView.NewKeyDownEvent (new (KeyCode.Tab));
15541557
Assert.Equal ("\tTAB to jump between text fields.", _textView.Text);
1558+
Application.Refresh ();
1559+
TestHelpers.AssertDriverContentsWithFrameAre (@"
1560+
TAB to jump between text field", _output);
1561+
1562+
_textView.TabWidth = 4;
1563+
Application.Refresh ();
1564+
TestHelpers.AssertDriverContentsWithFrameAre (@"
1565+
TAB to jump between text f", _output);
1566+
15551567
_textView.NewKeyDownEvent (new (KeyCode.Tab | KeyCode.ShiftMask));
15561568
Assert.Equal ("TAB to jump between text fields.", _textView.Text);
1569+
Assert.True (_textView.NeedsDisplay);
1570+
Application.Refresh ();
1571+
TestHelpers.AssertDriverContentsWithFrameAre (@"
1572+
TAB to jump between text field", _output);
15571573
}
15581574

15591575
[Fact]

0 commit comments

Comments
 (0)