diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2013-10-29 10:06:37 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2013-10-29 10:06:56 +0400 |
commit | 46af0b4759116709dc6ecd78998a055c63f64a1e (patch) | |
tree | 2a56ff0ecb93aa9d305bdfcf43ba5e794d4de02f /main/src/core | |
parent | 2349fbd0d7199ec23213f5c08967c68ee02c36b4 (diff) |
Fixed 'Bug 15476 - Cursor is getting stuck when deleting last empty
line with indents '.
Diffstat (limited to 'main/src/core')
-rw-r--r-- | main/src/core/Mono.Texteditor/Mono.TextEditor/Actions/DeleteActions.cs | 1 | ||||
-rw-r--r-- | main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/VirtualIndentModeTests.cs | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Actions/DeleteActions.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Actions/DeleteActions.cs index 526960a89f..bcbd9b8910 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Actions/DeleteActions.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Actions/DeleteActions.cs @@ -212,6 +212,7 @@ namespace Mono.TextEditor } else if (data.Caret.Offset == line.Offset) { DocumentLine lineAbove = data.Document.GetLine (data.Caret.Line - 1); if (lineAbove.Length == 0 && data.HasIndentationTracker && data.Options.IndentStyle == IndentStyle.Virtual) { + data.Caret.Location = new DocumentLocation (data.Caret.Line - 1, data.IndentationTracker.GetVirtualIndentationColumn (data.Caret.Line - 1, 1)); data.Replace (lineAbove.EndOffsetIncludingDelimiter - lineAbove.DelimiterLength, lineAbove.DelimiterLength, data.IndentationTracker.GetIndentationString (data.Caret.Line - 1, 1)); } else { data.Remove (lineAbove.EndOffsetIncludingDelimiter - lineAbove.DelimiterLength, lineAbove.DelimiterLength); diff --git a/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/VirtualIndentModeTests.cs b/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/VirtualIndentModeTests.cs index 8c62fbc7ab..a163c4dcec 100644 --- a/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/VirtualIndentModeTests.cs +++ b/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/VirtualIndentModeTests.cs @@ -442,6 +442,28 @@ namespace Mono.TextEditor.Tests Assert.AreEqual (new DocumentLocation (2, 3), data.MainSelection.Anchor); } + + /// <summary> + /// Bug 15476 - Cursor is getting stuck when deleting last empty line with indents + /// </summary> + [Test] + public void TestBug15476 () + { + var data = CreateData ("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n\t\t\r\n\r\n"); + data.Options.DefaultEolMarker = "\r\n"; + data.IndentationTracker = new DefaultIndentationTracker (data.Document); + data.Caret.Location = new DocumentLocation (4, 3); + + DeleteActions.Backspace (data); + Assert.AreEqual (new DocumentLocation (4, 2), data.Caret.Location); + DeleteActions.Backspace (data); + Assert.AreEqual (new DocumentLocation (4, 1), data.Caret.Location); + + DeleteActions.Backspace (data); + Assert.AreEqual (new DocumentLocation (3, 3), data.Caret.Location); + + } + } } |