protected override void HandleCharactersEntered(string characters) { string previous = text; text = SelectionRangeUtil.InsertText(text, ref selectionRange, characters); HandleTextChanged(previous); }
public void DeleteTextSelectionOnInsert() { string text = "Keep|Delete|Keep"; SelectionRange range = GetSelectionFromCharacters(ref text); string expected = "KeepInsertedKeep"; string result = SelectionRangeUtil.InsertText(text, ref range, "Inserted"); Assert.AreEqual(expected, result); AssertSelection(result, range, "KeepInserted|Keep"); }
public void PrependTextToNonEmptyString() { string text = "|CONTENT"; SelectionRange range = GetCursorFromCharacter(ref text); string toAdd = "this is added"; string result = SelectionRangeUtil.InsertText(text, ref range, toAdd); Assert.AreEqual(toAdd + text, result); AssertSelection(result, range, "this is added|CONTENT"); }
public void AppendTextToNonEmptyString() { string text = "CONTENT |"; SelectionRange range = GetCursorFromCharacter(ref text); string toAdd = "this is added"; string result = SelectionRangeUtil.InsertText(text, ref range, toAdd); Assert.AreEqual(text + toAdd, result); AssertRangesEqual(new SelectionRange((text + toAdd).Length), range); }
public void InsertTextToNonEmptyString() { string text = "INSERT|HERE"; SelectionRange range = GetCursorFromCharacter(ref text); string toAdd = "this is added"; string expected = "INSERTthis is addedHERE"; string result = SelectionRangeUtil.InsertText(text, ref range, toAdd); Assert.AreEqual(expected, result); AssertSelection(result, range, "INSERTthis is added|HERE"); }
public void InsertWhitespaceToNonEmptyString() { string text = "Randomword|"; SelectionRange range = GetCursorFromCharacter(ref text); string toAdd = " "; string expected = "Randomword another"; string result = SelectionRangeUtil.InsertText(text, ref range, toAdd); result = SelectionRangeUtil.InsertText(result, ref range, "another"); Assert.AreEqual(expected, result); AssertSelection(result, range, "Randomword another|"); }
public void DeleteTextRangeForwardFromEnd() { string text = "Keep|Delete|"; SelectionRange range = GetSelectionFromCharacters(ref text); string expected = "Keep"; string result = SelectionRangeUtil.DeleteTextForwards(text, ref range); Assert.AreEqual(expected, result); AssertSelection(result, range, "Keep|"); string toAdd = " "; result = SelectionRangeUtil.InsertText(result, ref range, toAdd); Assert.AreEqual("Keep ", result); AssertSelection(result, range, "Keep |"); }