Browse Source

When switching to the text editor window after designing a Wix dialog or adding new files in the Setup Files window the updated text is now selected in the text editor.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5282 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Matt Ward 17 years ago
parent
commit
d8c7949a09
  1. 16
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDocumentEditor.cs
  2. 9
      src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentEditorInsertTextTestFixture.cs
  3. 9
      src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentEditorReplaceTextTestFixture.cs
  4. 3
      src/AddIns/BackendBindings/WixBinding/Test/Utils/MockTextEditor.cs
  5. 12
      src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockTextEditorTests.cs

16
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDocumentEditor.cs

@ -66,14 +66,12 @@ namespace ICSharpCode.WixBinding
// Indent the xml. // Indent the xml.
int insertedCharacterCount = IndentAllLinesTheSame(region.BeginLine + 1, region.EndLine + addedLineCount, initialIndent); int insertedCharacterCount = IndentAllLinesTheSame(region.BeginLine + 1, region.EndLine + addedLineCount, initialIndent);
// Select the text just inserted.
int textInsertedLength = insertedCharacterCount + xml.Length;
textEditor.Select(segment.Offset, textInsertedLength);
// Make sure the text inserted is visible. // Make sure the text inserted is visible.
textEditor.JumpTo(region.BeginLine + 1, 1); textEditor.JumpTo(region.BeginLine + 1, 1);
textEditor.Caret.Position = document.OffsetToPosition(segment.Offset + textInsertedLength); // Select the text just inserted.
int textInsertedLength = insertedCharacterCount + xml.Length;
textEditor.Select(segment.Offset, textInsertedLength);
} }
} }
@ -103,14 +101,12 @@ namespace ICSharpCode.WixBinding
// Indent the xml. // Indent the xml.
int insertedCharacterCount = IndentLines(line, line + addedLineCount, initialIndent); int insertedCharacterCount = IndentLines(line, line + addedLineCount, initialIndent);
// Select the text just inserted.
int textInsertedLength = xml.Length + insertedCharacterCount;
textEditor.Select(offset, textInsertedLength);
// Make sure the text inserted is visible. // Make sure the text inserted is visible.
textEditor.JumpTo(line + 1, 1); textEditor.JumpTo(line + 1, 1);
textEditor.Caret.Position = document.OffsetToPosition(offset + textInsertedLength); // Select the text just inserted.
int textInsertedLength = xml.Length + insertedCharacterCount;
textEditor.Select(offset, textInsertedLength);
} }
} }

9
src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentEditorInsertTextTestFixture.cs

@ -86,15 +86,6 @@ namespace WixBinding.Tests.Gui
Assert.AreEqual(expectedText, textEditor.SelectedText); Assert.AreEqual(expectedText, textEditor.SelectedText);
} }
[Test]
public void CursorAtEndOfSelectedText()
{
int col = 2;
int line = 5;
Location expectedLocation = new Location(col, line);
Assert.AreEqual(expectedLocation, textEditor.Caret.Position);
}
[Test] [Test]
public void InsertCanBeUndoneInOneStep() public void InsertCanBeUndoneInOneStep()
{ {

9
src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentEditorReplaceTextTestFixture.cs

@ -94,15 +94,6 @@ namespace WixBinding.Tests.Gui
Assert.AreEqual(expectedText, textEditor.SelectedText); Assert.AreEqual(expectedText, textEditor.SelectedText);
} }
[Test]
public void CursorAtEndOfSelectedText()
{
int col = 14;
int line = 3;
Location expectedLocation = new Location(col, line);
Assert.AreEqual(expectedLocation, textEditor.Caret.Position);
}
[Test] [Test]
public void InsertCanBeUndoneInOneStep() public void InsertCanBeUndoneInOneStep()
{ {

3
src/AddIns/BackendBindings/WixBinding/Test/Utils/MockTextEditor.cs

@ -140,7 +140,8 @@ namespace WixBinding.Tests.Utils
public void JumpTo(int line, int column) public void JumpTo(int line, int column)
{ {
locationJumpedTo = new Location(column, line); locationJumpedTo = new Location(column, line);
} selection = new SimpleSelection(-1, -1);
}
public Location LocationJumpedTo { public Location LocationJumpedTo {
get { return locationJumpedTo; } get { return locationJumpedTo; }

12
src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockTextEditorTests.cs

@ -116,5 +116,17 @@ namespace WixBinding.Tests.Utils.Tests
Assert.AreEqual("abc-replaced-ghi", textEditor.Document.Text); Assert.AreEqual("abc-replaced-ghi", textEditor.Document.Text);
} }
[Test]
public void NoTextSelectedAfterJumpToMethodIsCalled()
{
int offset = 1;
int length = 2;
textEditor.Document.Text = "test\r\nsecond line";
textEditor.Select(offset, length);
textEditor.JumpTo(2, 1);
Assert.AreEqual(String.Empty, textEditor.SelectedText);
}
} }
} }

Loading…
Cancel
Save