Skip to content

Commit

Permalink
Fix #51: caret movement when inserting new line with DefaultIndentati…
Browse files Browse the repository at this point in the history
…onStrategy and there are spaces to the right of the caret
  • Loading branch information
dgrunwald committed Dec 13, 2015
1 parent 8635131 commit 5c55017
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -41,7 +41,9 @@ public virtual void IndentLine(TextDocument document, DocumentLine line)
string indentation = document.GetText(indentationSegment);
// copy indentation to line
indentationSegment = TextUtilities.GetWhitespaceAfter(document, line.Offset);
document.Replace(indentationSegment, indentation);
document.Replace(indentationSegment.Offset, indentation.Length, indentation,
OffsetChangeMappingType.RemoveAndInsert);

This comment has been minimized.

Copy link
@anakic

anakic Dec 25, 2015

Contributor

Is passing "indentation.Length" as the second parameter a mistake? Shouldn't it be "indentationSegment.Lenght"? The documentation for the second parameter says "The length of the text to be replaced" but here the length of the indentation is passed instead of the length of the selection. Here's an example of where this produces a bug:

SELECT 
    * 
FROM 
    Table1  INNER join Table1

Position cursor on INNER (just before I), and press enter. The I is replaced by \t.

// OffsetChangeMappingType.RemoveAndInsert guarantees the caret moves behind the new indentation.
}
}

Expand Down

0 comments on commit 5c55017

Please sign in to comment.