Browse Source

Fixes #3034. Text remains "invisible" in the TextView when WordWrap is activated. (#3036)

BDisp 1 year ago
parent
commit
8f1b5aceb6
2 changed files with 34 additions and 1 deletions
  1. 3 1
      Terminal.Gui/Views/TextView.cs
  2. 31 0
      UnitTests/Views/TextViewTests.cs

+ 3 - 1
Terminal.Gui/Views/TextView.cs

@@ -2881,7 +2881,9 @@ namespace Terminal.Gui {
 				_selectionStartRow = nStartRow;
 				_selectionStartColumn = nStartCol;
 				_wrapNeeded = true;
-			}
+
+                SetNeedsDisplay();
+            }
 			if (_currentCaller != null)
 				throw new InvalidOperationException ($"WordWrap settings was changed after the {_currentCaller} call.");
 		}

+ 31 - 0
UnitTests/Views/TextViewTests.cs

@@ -6977,5 +6977,36 @@ This is the second line.
 				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);
+		}
 	}
 }