diff --git a/src/AddIns/BackendBindings/Scripting/Project/Src/IScriptingConsoleTextEditor.cs b/src/AddIns/BackendBindings/Scripting/Project/Src/IScriptingConsoleTextEditor.cs
index 7320a12487..6ec7bddebc 100644
--- a/src/AddIns/BackendBindings/Scripting/Project/Src/IScriptingConsoleTextEditor.cs
+++ b/src/AddIns/BackendBindings/Scripting/Project/Src/IScriptingConsoleTextEditor.cs
@@ -24,9 +24,9 @@ namespace ICSharpCode.Scripting
event ConsoleTextEditorKeyEventHandler PreviewKeyDown;
///
- /// Inserts text at the current cursor location.
+ /// Appends text to the end of the text editor.
///
- void Write(string text);
+ void Append(string text);
///
/// Replaces the text at the specified index on the current line with the specified text.
diff --git a/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsole.cs b/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsole.cs
index 91e5821f57..a83aedf877 100644
--- a/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsole.cs
+++ b/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsole.cs
@@ -70,7 +70,7 @@ namespace ICSharpCode.Scripting
///
public void Write(string text, ScriptingStyle style)
{
- textEditor.Write(text);
+ textEditor.Append(text);
if (style == ScriptingStyle.Prompt) {
firstPromptDisplayed = true;
promptLength = text.Length;
@@ -89,7 +89,7 @@ namespace ICSharpCode.Scripting
{
if (textSent.HasLine) {
string line = textSent.RemoveFirstLine();
- textEditor.Write(line);
+ textEditor.Append(line);
}
}
diff --git a/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsoleOutputStream.cs b/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsoleOutputStream.cs
index 115ee9cb28..0e7032ea3e 100644
--- a/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsoleOutputStream.cs
+++ b/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsoleOutputStream.cs
@@ -69,7 +69,7 @@ namespace ICSharpCode.Scripting
void ThreadSafeTextEditorWrite(string text)
{
if (dispatcher.CheckAccess()) {
- textEditor.Write(text);
+ textEditor.Append(text);
} else {
Action action = ThreadSafeTextEditorWrite;
dispatcher.Invoke(action, text);
diff --git a/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsoleTextEditor.cs b/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsoleTextEditor.cs
index f73cb3fdf6..c96176bcfc 100644
--- a/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsoleTextEditor.cs
+++ b/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsoleTextEditor.cs
@@ -44,16 +44,9 @@ namespace ICSharpCode.Scripting
textEditor.PreviewKeyDown -= OnTextEditorPreviewKeyDown;
}
- public void Write(string text)
+ public void Append(string text)
{
- TextLocation location = GetCurrentCursorLocation();
- int offset = textEditor.Document.GetOffset(location);
- textEditor.Document.Insert(offset, text);
- }
-
- TextLocation GetCurrentCursorLocation()
- {
- return new TextLocation(Line + 1, Column + 1);
+ textEditor.AppendText(text);
}
public int Column {
diff --git a/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleOutputStreamTests.cs b/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleOutputStreamTests.cs
index f913ea9e74..21ac71246f 100644
--- a/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleOutputStreamTests.cs
+++ b/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleOutputStreamTests.cs
@@ -52,7 +52,7 @@ namespace ICSharpCode.Scripting.Tests.Console
byte[] bytes = UTF8Encoding.UTF8.GetBytes("test");
stream.Write(bytes, 0, bytes.Length);
- string text = textEditor.TextPassedToWrite;
+ string text = textEditor.TextPassedToAppend;
string expectedText = "test";
Assert.AreEqual(expectedText, text);
@@ -65,7 +65,7 @@ namespace ICSharpCode.Scripting.Tests.Console
byte[] bytes = UTF8Encoding.UTF8.GetBytes("0output1");
stream.Write(bytes, 1, bytes.Length - 2);
- string text = textEditor.TextPassedToWrite;
+ string text = textEditor.TextPassedToAppend;
string expectedText = "output";
Assert.AreEqual(expectedText, text);
diff --git a/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleReadTests.cs b/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleReadTests.cs
index 4944bf1006..9af1e21254 100644
--- a/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleReadTests.cs
+++ b/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleReadTests.cs
@@ -28,7 +28,7 @@ namespace ICSharpCode.Scripting.Tests.Console
TestableScriptingConsole.ReadLine(indent);
string expectedText = " ";
- Assert.AreEqual(expectedText, FakeConsoleTextEditor.TextPassedToWrite);
+ Assert.AreEqual(expectedText, FakeConsoleTextEditor.TextPassedToAppend);
}
[Test]
@@ -38,11 +38,11 @@ namespace ICSharpCode.Scripting.Tests.Console
FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.A);
FakeConsoleTextEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
- FakeConsoleTextEditor.IsWriteCalled = false;
+ FakeConsoleTextEditor.IsAppendCalled = false;
TestableScriptingConsole.ReadLine(0);
- Assert.IsFalse(FakeConsoleTextEditor.IsWriteCalled);
+ Assert.IsFalse(FakeConsoleTextEditor.IsAppendCalled);
}
[Test]
diff --git a/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleSendLineTests.cs b/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleSendLineTests.cs
index fd43e342a3..d46abb8ceb 100644
--- a/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleSendLineTests.cs
+++ b/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleSendLineTests.cs
@@ -52,41 +52,18 @@ namespace ICSharpCode.Scripting.Tests.Console
public void SendLine_NoUnreadLines_LineWrittenToConsoleTextEditor()
{
SendLineToConsole("test");
- string text = FakeConsoleTextEditor.TextPassedToWrite;
+ string text = FakeConsoleTextEditor.TextPassedToAppend;
string expectedTextWritten = "test\r\n";
Assert.AreEqual(expectedTextWritten, text);
}
- [Test]
- public void SendLine_TwoLinesInConsoleTextEditorCursorOnFirstLine_CursorMovedToEndOfLastLineBeforeTextWritten()
- {
- base.CreateConsole();
- WritePrompt();
- FakeConsoleTextEditor.Text =
- ">>> first\r\n" +
- ">>> second\r\n" +
- ">>> ";
-
- FakeConsoleTextEditor.Line = 0;
- FakeConsoleTextEditor.Column = 0;
- TestableScriptingConsole.SendLine("test");
-
- int expectedLine = 2;
- int expectedColumn = 4;
- Location expectedLocation = new Location(expectedColumn, expectedLine);
-
- Location location = FakeConsoleTextEditor.CursorLocationWhenWriteTextCalled;
-
- Assert.AreEqual(expectedLocation, location);
- }
-
[Test]
public void SendLine_NoUnreadLines_NoTextWrittenToConsoleTextEditorBeforeFirstPromptIsWritten()
{
base.CreateConsole();
TestableScriptingConsole.SendLine("test");
- string text = FakeConsoleTextEditor.TextPassedToWrite;
+ string text = FakeConsoleTextEditor.TextPassedToAppend;
Assert.IsNull(text);
}
diff --git a/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleSendTextTests.cs b/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleSendTextTests.cs
index c43afd5597..c495ea9c92 100644
--- a/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleSendTextTests.cs
+++ b/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleSendTextTests.cs
@@ -17,7 +17,7 @@ namespace ICSharpCode.Scripting.Tests.Console
{
SendTextToConsole("test");
- string text = base.FakeConsoleTextEditor.TextPassedToWrite;
+ string text = base.FakeConsoleTextEditor.TextPassedToAppend;
string expectedText = "test";
Assert.AreEqual(expectedText, text);
}
@@ -29,32 +29,12 @@ namespace ICSharpCode.Scripting.Tests.Console
TestableScriptingConsole.SendText(text);
}
- [Test]
- public void SendText_TextEditorHasTextAfterPrompt_CursorMovedToEndOfLastLineBeforeTextWritten()
- {
- base.CreateConsole();
- WritePrompt();
- FakeConsoleTextEditor.Text = ">>> first";
-
- FakeConsoleTextEditor.Line = -1;
- FakeConsoleTextEditor.Column = -1;
- TestableScriptingConsole.SendText("test");
-
- int expectedLine = 0;
- int expectedColumn = 9;
- Location expectedLocation = new Location(expectedColumn, expectedLine);
-
- Location location = FakeConsoleTextEditor.CursorLocationWhenWriteTextCalled;
-
- Assert.AreEqual(expectedLocation, location);
- }
-
[Test]
public void SendText_FirstPromptNotYetWrittenToConsole_NoTextWrittenToConsoleTextEditor()
{
base.CreateConsole();
TestableScriptingConsole.SendText("test");
- string text = FakeConsoleTextEditor.TextPassedToWrite;
+ string text = FakeConsoleTextEditor.TextPassedToAppend;
Assert.IsNull(text);
}
@@ -66,7 +46,7 @@ namespace ICSharpCode.Scripting.Tests.Console
TestableScriptingConsole.SendText("test");
TestableScriptingConsole.Write(">>> ", ScriptingStyle.Prompt);
- string text = FakeConsoleTextEditor.TextPassedToWrite;
+ string text = FakeConsoleTextEditor.TextPassedToAppend;
string expectedText = "test";
Assert.AreEqual(expectedText, text);
@@ -84,7 +64,7 @@ namespace ICSharpCode.Scripting.Tests.Console
TestableScriptingConsole.Write(">>> ", ScriptingStyle.Prompt);
TestableScriptingConsole.Write(">>> ", ScriptingStyle.Prompt);
- string textPassedToWrite = FakeConsoleTextEditor.TextPassedToWrite;
+ string textPassedToWrite = FakeConsoleTextEditor.TextPassedToAppend;
string expectedText = "second";
Assert.AreEqual(expectedText, textPassedToWrite);
@@ -99,7 +79,7 @@ namespace ICSharpCode.Scripting.Tests.Console
SendTextToConsole(selectedText);
- string text = base.FakeConsoleTextEditor.TextPassedToWrite;
+ string text = base.FakeConsoleTextEditor.TextPassedToAppend;
string expectedText = "first\r\n";
Assert.AreEqual(expectedText, text);
}
@@ -114,7 +94,7 @@ namespace ICSharpCode.Scripting.Tests.Console
SendTextToConsole(selectedText);
WritePrompt();
- string text = base.FakeConsoleTextEditor.TextPassedToWrite;
+ string text = base.FakeConsoleTextEditor.TextPassedToAppend;
string expectedText = "second";
Assert.AreEqual(expectedText, text);
}
diff --git a/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleTextEditorTests.cs b/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleTextEditorTests.cs
index 98c321fba3..c78dfdbaa4 100644
--- a/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleTextEditorTests.cs
+++ b/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleTextEditorTests.cs
@@ -38,7 +38,7 @@ namespace ICSharpCode.Scripting.Tests.Console
public void MakeCurrentContentReadOnly_OneLineOfTextInTextEditor_ExtendsReadOnlyRegionToEntireDocument()
{
avalonEditTextEditor.Text = String.Empty;
- consoleTextEditor.Write("abc" + Environment.NewLine);
+ consoleTextEditor.Append("abc" + Environment.NewLine);
consoleTextEditor.MakeCurrentContentReadOnly();
IReadOnlySectionProvider readOnlySection = avalonEditTextEditor.TextArea.ReadOnlySectionProvider;
@@ -47,10 +47,10 @@ namespace ICSharpCode.Scripting.Tests.Console
}
[Test]
- public void Write_TextEditorHasNoText_UpdatesTextEditor()
+ public void Append_TextEditorHasNoText_UpdatesTextEditor()
{
avalonEditTextEditor.Text = String.Empty;
- consoleTextEditor.Write("abc");
+ consoleTextEditor.Append("abc");
string text = avalonEditTextEditor.Text;
string expectedText = "abc";
@@ -58,6 +58,19 @@ namespace ICSharpCode.Scripting.Tests.Console
Assert.AreEqual(expectedText, text);
}
+ [Test]
+ public void Append_CursorNotAtEndOfText_TextIsWrittenAtEnd()
+ {
+ avalonEditTextEditor.Text = "abc";
+ avalonEditTextEditor.CaretOffset = 0;
+ consoleTextEditor.Append("d");
+
+ string text = avalonEditTextEditor.Text;
+ string expectedText = "abcd";
+
+ Assert.AreEqual(expectedText, text);
+ }
+
[Test]
public void Column_TextEditorColumnSetToThree_ZeroBasedConsoleTextEditorColumnPositionReturnsTwoWhichIsOneLessThanAvalonTextEditorColumnPositionWhichIsOneBased()
{
diff --git a/src/AddIns/BackendBindings/Scripting/Test/Utils/FakeConsoleTextEditor.cs b/src/AddIns/BackendBindings/Scripting/Test/Utils/FakeConsoleTextEditor.cs
index 9df5aa77b8..daeb379539 100644
--- a/src/AddIns/BackendBindings/Scripting/Test/Utils/FakeConsoleTextEditor.cs
+++ b/src/AddIns/BackendBindings/Scripting/Test/Utils/FakeConsoleTextEditor.cs
@@ -15,16 +15,15 @@ namespace ICSharpCode.Scripting.Tests.Utils
public class FakeConsoleTextEditor : IScriptingConsoleTextEditor
{
public bool IsDisposed;
- public bool IsWriteCalled;
+ public bool IsAppendCalled;
public bool IsShowCompletionWindowCalled;
public bool IsMakeCurrentContentReadOnlyCalled;
public ScriptingConsoleCompletionDataProvider CompletionProviderPassedToShowCompletionWindow;
- public string TextPassedToWrite;
+ public string TextPassedToAppend;
public string TextPassedToReplace;
public int LengthPassedToReplace = -1;
public int IndexPassedToReplace = -1;
- public Location CursorLocationWhenWriteTextCalled;
public bool IsColumnChangedBeforeTextWritten;
public StringBuilder PreviousLines = new StringBuilder();
@@ -42,11 +41,10 @@ namespace ICSharpCode.Scripting.Tests.Utils
IsDisposed = true;
}
- public void Write(string text)
+ public void Append(string text)
{
- TextPassedToWrite = text;
- CursorLocationWhenWriteTextCalled = new Location(Column, Line);
- IsWriteCalled = true;
+ TextPassedToAppend = text;
+ IsAppendCalled = true;
LineBuilder.Append(text);
Column += text.Length;
}
diff --git a/src/AddIns/BackendBindings/Scripting/Test/Utils/Tests/MockConsoleTextEditorTests.cs b/src/AddIns/BackendBindings/Scripting/Test/Utils/Tests/MockConsoleTextEditorTests.cs
index 145a35e3c5..4bb0a43bf0 100644
--- a/src/AddIns/BackendBindings/Scripting/Test/Utils/Tests/MockConsoleTextEditorTests.cs
+++ b/src/AddIns/BackendBindings/Scripting/Test/Utils/Tests/MockConsoleTextEditorTests.cs
@@ -26,40 +26,40 @@ namespace ICSharpCode.Scripting.Tests.Utils.Tests
}
[Test]
- public void TextReturnsTextWritten()
+ public void TextReturnsTextAppended()
{
- textEditor.Write("abc");
+ textEditor.Append("abc");
Assert.AreEqual("abc", textEditor.Text);
}
[Test]
- public void ColumnReturnsPositionAfterTextWritten()
+ public void ColumnReturnsPositionAfterTextAppended()
{
- textEditor.Write("ab");
+ textEditor.Append("ab");
Assert.AreEqual(2, textEditor.Column);
}
[Test]
- public void TextReturnsAllTextWritten()
+ public void TextReturnsAllTextAppended()
{
- textEditor.Write("a");
- textEditor.Write("b");
+ textEditor.Append("a");
+ textEditor.Append("b");
Assert.AreEqual("ab", textEditor.Text);
}
[Test]
- public void ColumnReturnsPositionAfterTextWhenWriteCalledTwice()
+ public void ColumnReturnsPositionAfterTextWhenAppendCalledTwice()
{
- textEditor.Write("a");
- textEditor.Write("bb");
+ textEditor.Append("a");
+ textEditor.Append("bb");
Assert.AreEqual(3, textEditor.Column);
}
[Test]
- public void IsWriteCalledReturnsTrueAfterWriteMethodCalled()
+ public void IsAppendCalledReturnsTrueAfterAppendMethodCalled()
{
- textEditor.Write("a");
- Assert.IsTrue(textEditor.IsWriteCalled);
+ textEditor.Append("a");
+ Assert.IsTrue(textEditor.IsAppendCalled);
}
[Test]