Fixes #2429. Error when replacing a word in textView.

This commit is contained in:
BDisp
2023-03-22 13:45:02 +00:00
parent 5b00dcfd04
commit 1525c5021e

View File

@@ -949,7 +949,7 @@ namespace Terminal.Gui.ViewTests {
Assert.Equal (0, _textView.CursorPosition.X);
Assert.Equal (0, _textView.CursorPosition.Y);
Assert.Equal ("This is the second line.", _textView.Text.ToString ());
Assert.Equal ($"This is the first line.{Environment.NewLine}", Clipboard.Contents.ToString());
Assert.Equal ($"This is the first line.{Environment.NewLine}", Clipboard.Contents.ToString ());
break;
case 2:
_textView.ProcessKey (new KeyEvent (Key.K | Key.CtrlMask, new KeyModifiers ()));
@@ -985,7 +985,7 @@ namespace Terminal.Gui.ViewTests {
_textView.ProcessKey (new KeyEvent (Key.K | Key.AltMask, new KeyModifiers ()));
Assert.Equal (0, _textView.CursorPosition.X);
Assert.Equal (1, _textView.CursorPosition.Y);
Assert.Equal ($"This is the first line.{Environment.NewLine}", _textView.Text.ToString());
Assert.Equal ($"This is the first line.{Environment.NewLine}", _textView.Text.ToString ());
Assert.Equal ($"This is the second line.", Clipboard.Contents.ToString ());
break;
case 1:
@@ -6815,5 +6815,17 @@ This is the second line.
Assert.Equal (1, eventcount);
Assert.Equal ($"This is the first line.{Environment.NewLine}This is the second line.{Environment.NewLine}", tv.Text);
}
[Fact]
public void ReplaceAllText_Does_Not_Throw_Exception ()
{
var textToFind = "hello! hello!";
var textToReplace = "hello!";
var tv = new TextView () { Width = 20, Height = 3, Text = textToFind };
var exception = Record.Exception (() => tv.ReplaceAllText (textToFind, false, false, textToReplace));
Assert.Null (exception);
Assert.Equal (textToReplace, tv.Text);
}
}
}