diff --git a/src/AddIns/BackendBindings/Scripting/Test/Console/InsertConsoleCompletionDataTestFixture.cs b/src/AddIns/BackendBindings/Scripting/Test/Console/InsertConsoleCompletionDataTestFixture.cs index 6d7e8c2b91..6a3cda57c9 100644 --- a/src/AddIns/BackendBindings/Scripting/Test/Console/InsertConsoleCompletionDataTestFixture.cs +++ b/src/AddIns/BackendBindings/Scripting/Test/Console/InsertConsoleCompletionDataTestFixture.cs @@ -30,10 +30,10 @@ namespace ICSharpCode.Scripting.Tests.Console int startOffset = 4; int endOffset = 5; - SimpleSelection selection = new SimpleSelection(startOffset, endOffset); + Selection selection = Selection.Create(textEditor.TextArea, startOffset, endOffset); completionData = new ScriptingConsoleCompletionData("new"); - completionData.Complete(textEditor.TextArea, selection, null); + completionData.Complete(textEditor.TextArea, selection.SurroundingSegment, null); string expectedText = "abc.new"; diff --git a/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleTextEditorTests.cs b/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleTextEditorTests.cs index 7b484cd20f..1999949d38 100644 --- a/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleTextEditorTests.cs +++ b/src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleTextEditorTests.cs @@ -102,8 +102,8 @@ namespace ICSharpCode.Scripting.Tests.Console avalonEditTextEditor.Text = "te000xt"; int startOffset = 2; int endOffset = 5; - SimpleSelection expectedSelection = new SimpleSelection(startOffset, endOffset); - avalonEditTextEditor.SelectionStart = expectedSelection.StartOffset; + Selection expectedSelection = Selection.Create(avalonEditTextEditor.TextArea, startOffset, endOffset); + avalonEditTextEditor.SelectionStart = expectedSelection.SurroundingSegment.Offset; avalonEditTextEditor.SelectionLength = expectedSelection.Length; // Sanity check. @@ -112,10 +112,10 @@ namespace ICSharpCode.Scripting.Tests.Console AssertSelectionsAreEqual(expectedSelection, consoleTextEditor); } - void AssertSelectionsAreEqual(SimpleSelection expectedSelection, IScriptingConsoleTextEditor consoleTextEditor) + void AssertSelectionsAreEqual(Selection expectedSelection, IScriptingConsoleTextEditor consoleTextEditor) { - int selectionLength = consoleTextEditor.SelectionStart + consoleTextEditor.SelectionLength; - SimpleSelection actualSelection = new SimpleSelection(consoleTextEditor.SelectionStart, selectionLength); + int selectionEnd = consoleTextEditor.SelectionStart + consoleTextEditor.SelectionLength; + Selection actualSelection = Selection.Create(avalonEditTextEditor.TextArea, consoleTextEditor.SelectionStart, selectionEnd); Assert.AreEqual(expectedSelection, actualSelection); } @@ -126,7 +126,7 @@ namespace ICSharpCode.Scripting.Tests.Console avalonEditTextEditor.TextArea.Caret.Column = 1; avalonEditTextEditor.SelectionLength = 0; - SimpleSelection expectedSelection = new SimpleSelection(1, 1); + Selection expectedSelection = Selection.Create(avalonEditTextEditor.TextArea, 1, 1); AssertSelectionsAreEqual(expectedSelection, consoleTextEditor); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockTextEditor.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockTextEditor.cs index 127885a93a..b2d38c6114 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockTextEditor.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockTextEditor.cs @@ -21,12 +21,16 @@ namespace WixBinding.Tests.Utils AvalonEditDocumentAdapter documentAdapter; MockCaret caret = new MockCaret(); Location locationJumpedTo = Location.Empty; - SimpleSelection selection = new SimpleSelection(-1, -1); + Selection selection; MockTextEditorOptions options = new MockTextEditorOptions(); + TextArea textArea; public MockTextEditor() { documentAdapter = new AvalonEditDocumentAdapter(textDocument, null); + textArea = new TextArea(); + textArea.Document = textDocument; + selection = Selection.Create(textArea, -1, -1); } public event EventHandler SelectionChanged; @@ -103,7 +107,7 @@ namespace WixBinding.Tests.Utils if (selection.IsEmpty) { return String.Empty; } - return documentAdapter.GetText(selection.StartOffset, selection.Length); + return documentAdapter.GetText(selection.SurroundingSegment.Offset, selection.Length); } set { throw new NotImplementedException(); @@ -130,13 +134,13 @@ namespace WixBinding.Tests.Utils public void Select(int selectionStart, int selectionLength) { - selection = new SimpleSelection(selectionStart, selectionLength + selectionStart); + selection = Selection.Create(textArea, selectionStart, selectionLength + selectionStart); } public void JumpTo(int line, int column) { locationJumpedTo = new Location(column, line); - selection = new SimpleSelection(-1, -1); + selection = Selection.Create(textArea, -1, -1); } public Location LocationJumpedTo { diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Editing/ChangeDocumentTests.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Editing/ChangeDocumentTests.cs index 07587ea8c8..609ddf3075 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Editing/ChangeDocumentTests.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Editing/ChangeDocumentTests.cs @@ -17,11 +17,11 @@ namespace ICSharpCode.AvalonEdit.Editing TextArea textArea = new TextArea(); textArea.Document = new TextDocument("1\n2\n3\n4th line"); textArea.Caret.Offset = 6; - textArea.Selection = new SimpleSelection(3, 6); + textArea.Selection = Selection.Create(textArea, 3, 6); textArea.Document = new TextDocument("1\n2nd"); Assert.AreEqual(0, textArea.Caret.Offset); Assert.AreEqual(new TextLocation(1, 1), textArea.Caret.Location); - Assert.AreSame(Selection.Empty, textArea.Selection); + Assert.IsTrue(textArea.Selection.IsEmpty); } [Test] @@ -30,11 +30,11 @@ namespace ICSharpCode.AvalonEdit.Editing TextArea textArea = new TextArea(); textArea.Document = new TextDocument("1\n2\n3\n4th line"); textArea.Caret.Offset = 6; - textArea.Selection = new SimpleSelection(3, 6); + textArea.Selection = Selection.Create(textArea, 3, 6); textArea.Document = null; Assert.AreEqual(0, textArea.Caret.Offset); Assert.AreEqual(new TextLocation(1, 1), textArea.Caret.Location); - Assert.AreSame(Selection.Empty, textArea.Selection); + Assert.IsTrue(textArea.Selection.IsEmpty); } [Test]