Explorar el Código

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

BDisp hace 1 año
padre
commit
577fae1ac7
Se han modificado 2 ficheros con 33 adiciones y 1 borrados
  1. 2 1
      Terminal.Gui/Views/TextView.cs
  2. 31 0
      UnitTests/Views/TextViewTests.cs

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

@@ -2344,6 +2344,8 @@ namespace Terminal.Gui {
 				selectionStartRow = nStartRow;
 				selectionStartColumn = nStartCol;
 				wrapNeeded = true;
+
+				SetNeedsDisplay ();
 			}
 			if (currentCaller != null)
 				throw new InvalidOperationException ($"WordWrap settings was changed after the {currentCaller} call.");
@@ -2531,7 +2533,6 @@ namespace Terminal.Gui {
 			if (!wrapNeeded) {
 				SetNeedsDisplay (new Rect (0, prow, Math.Max (Frame.Width, 0), Math.Max (prow + 1, 0)));
 			}
-
 		}
 
 		ustring StringFromRunes (List<Rune> runes)

+ 31 - 0
UnitTests/Views/TextViewTests.cs

@@ -6857,5 +6857,36 @@ TAB to jump between text field", output);
  to jump between text fields.
  to jump between text fields.", output);
 		}
+
+		[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.NeedDisplay);
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+H      
+Line 2.", output);
+		}
 	}
 }