From 74bbb274c02db6043b0bec082e6cbc1305ef04b9 Mon Sep 17 00:00:00 2001 From: Andreas Weizel Date: Fri, 7 Jun 2013 00:34:40 +0200 Subject: [PATCH] Fixed bug in moving code lines with appended comments: Code and comment were not kept together. --- .../CSharpBinding/Project/Src/CodeManipulation.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CodeManipulation.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CodeManipulation.cs index 64912fa231..72a9dacb4b 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CodeManipulation.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CodeManipulation.cs @@ -158,11 +158,15 @@ namespace CSharpBinding if (swapIndex < 0 || swapIndex >= siblings.Count) return; AstNode swapSibling = siblings[swapIndex]; + Selection swapSiblingSelection = ExtendSelectionToComments(editor.Document, swapSibling.StartLocation, swapSibling.EndLocation, commentsBlankLines); + if (swapSiblingSelection == null) + swapSiblingSelection = new Selection() { Start = swapSibling.StartLocation, End = swapSibling.EndLocation }; // Swap them string currentNodeText = editor.Document.GetText(statementSelection.Start, statementSelection.End); - SwapText(editor.Document, statementSelection.Start, statementSelection.End, swapSibling.StartLocation, swapSibling.EndLocation); +// SwapText(editor.Document, statementSelection.Start, statementSelection.End, swapSibling.StartLocation, swapSibling.EndLocation); + SwapText(editor.Document, statementSelection.Start, statementSelection.End, swapSiblingSelection.Start, swapSiblingSelection.End); // Move caret to the start of moved statement - TextLocation upperLocation = new TextLocation[] {statementSelection.Start, swapSibling.StartLocation}.Min(); + TextLocation upperLocation = new TextLocation[] {statementSelection.Start, swapSiblingSelection.Start}.Min(); if (direction == MoveStatementDirection.Up) editor.Caret.Location = upperLocation; else {