[mono/monodevelop] [2 commits] 2349fbd0: [TextEditor] Fixed potential problem in height calculation.

Mike Krüger ([email protected]) <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <0000014202d462a7-a3ac4fa6-07f4-433a-8c7b-34718be90567-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/monodevelop
  Compare: https://github.com/mono/monodevelop/compare/b37834a48951...46af0b475911

   Commit: 2349fbd0d7199ec23213f5c08967c68ee02c36b4
   Author: Mike Krüger <[email protected]> (mkrueger)
     Date: 2013-10-29 06:06:55 GMT
      URL: https://github.com/mono/monodevelop/commit/2349fbd0d7199ec23213f5c08967c68ee02c36b4

[TextEditor] Fixed potential problem in height calculation.

Changed paths:
  M main/src/core/Mono.Texteditor/Mono.TextEditor/HeightTree.cs

Modified: main/src/core/Mono.Texteditor/Mono.TextEditor/HeightTree.cs
===================================================================
@@ -290,7 +290,7 @@ public void Unfold (FoldMarker marker, int lineNumber, int count)
 		public double LineNumberToY (int lineNumber)
 		{
 			int curLine = System.Math.Min (tree.Root.totalCount, lineNumber);
-			if (curLine < 0)
+			if (curLine <= 0)
 				return 0;
 			lock (tree) {
 				var node = GetSingleLineNode (curLine);

   Commit: 46af0b4759116709dc6ecd78998a055c63f64a1e
   Author: Mike Krüger <[email protected]> (mkrueger)
     Date: 2013-10-29 06:06:56 GMT
      URL: https://github.com/mono/monodevelop/commit/46af0b4759116709dc6ecd78998a055c63f64a1e

Fixed 'Bug 15476 - Cursor is getting stuck when deleting last empty
line with indents '.

Changed paths:
  M main/src/core/Mono.Texteditor/Mono.TextEditor/Actions/DeleteActions.cs
  M main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/VirtualIndentModeTests.cs

Modified: main/src/core/Mono.Texteditor/Mono.TextEditor/Actions/DeleteActions.cs
===================================================================
@@ -212,6 +212,7 @@ public static void Backspace (TextEditorData data, Action<TextEditorData> remove
 			} 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);

Modified: main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/VirtualIndentModeTests.cs
===================================================================
@@ -442,6 +442,28 @@ public void TestEmptyLineSelectionBehaviorMoveDown ()
 			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);
+
+		}
+
 	}
 }
 
_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.