Skip to content

Commit

Permalink
Merge branch 'v2_develop' into v2_textdirection-vertical-autosize_3017
Browse files Browse the repository at this point in the history
  • Loading branch information
tig authored Jan 5, 2024
2 parents 955b224 + e2a5905 commit 31bf5bf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Terminal.Gui/ConsoleDrivers/WindowsDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,8 @@ KeyCode MapKey (WindowsConsole.ConsoleKeyInfoEx keyInfoEx)

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));
}
Expand Down
5 changes: 5 additions & 0 deletions Terminal.Gui/Views/TextView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3373,6 +3373,9 @@ public void ScrollTo (int idx, bool isRow = true)
///<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;
Expand Down Expand Up @@ -3753,6 +3756,8 @@ bool ProcessBackTab ()
HistoryText.LineStatus.Replaced);
}

SetNeedsDisplay ();

UpdateWrapModel ();
}
DoNeededAction ();
Expand Down
16 changes: 16 additions & 0 deletions UnitTests/Views/TextViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,9 @@ public void Copy_Without_Selection ()
[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);
Expand All @@ -1552,8 +1555,21 @@ public void TabWidth_Setting_To_Zero_Keeps_AllowsTab ()
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]
Expand Down

0 comments on commit 31bf5bf

Please sign in to comment.