diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs index 3a746880bf..cca066948b 100644 --- a/Terminal.Gui/Views/TextView.cs +++ b/Terminal.Gui/Views/TextView.cs @@ -2881,7 +2881,9 @@ void UpdateWrapModel ([CallerMemberName] string? caller = null) _selectionStartRow = nStartRow; _selectionStartColumn = nStartCol; _wrapNeeded = true; - } + + SetNeedsDisplay(); + } if (_currentCaller != null) throw new InvalidOperationException ($"WordWrap settings was changed after the {_currentCaller} call."); } diff --git a/UnitTests/Views/TextViewTests.cs b/UnitTests/Views/TextViewTests.cs index 7485da2523..aa54b624a7 100644 --- a/UnitTests/Views/TextViewTests.cs +++ b/UnitTests/Views/TextViewTests.cs @@ -6977,5 +6977,36 @@ public void WordWrap_True_LoadStream_New_Text () Assert.True (_textView.WordWrap); } } + + [Theory] + [TextViewTestsAutoInitShutdown] + [InlineData (Key.Delete)] + [InlineData (Key.DeleteChar)] + public void WordWrap_Draw_Typed_Keys_After_Text_Is_Deleted (Key del) + { + Application.Top.Add (_textView); + _textView.Text = "Line 1.\nLine 2."; + _textView.WordWrap = true; + Application.Begin (Application.Top); + + Assert.True (_textView.WordWrap); + TestHelpers.AssertDriverContentsWithFrameAre (@" +Line 1. +Line 2.", output); + + Assert.True (_textView.ProcessKey (new KeyEvent (Key.End | Key.ShiftMask, new KeyModifiers () { Shift = true }))); + Assert.Equal ("Line 1.", _textView.SelectedText); + + Assert.True (_textView.ProcessKey (new KeyEvent (del, new KeyModifiers ()))); + Application.Refresh (); + TestHelpers.AssertDriverContentsWithFrameAre ("Line 2.", output); + + Assert.True (_textView.ProcessKey (new KeyEvent (Key.H, new KeyModifiers ()))); + Assert.NotEqual (Rect.Empty, _textView._needsDisplayRect); + Application.Refresh (); + TestHelpers.AssertDriverContentsWithFrameAre (@" +H +Line 2.", output); + } } } \ No newline at end of file