Skip to content

Commit 5c55017

Browse files
committed
Fix #51: caret movement when inserting new line with DefaultIndentationStrategy and there are spaces to the right of the caret
1 parent 8635131 commit 5c55017

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

ICSharpCode.AvalonEdit/Indentation/DefaultIndentationStrategy.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ public virtual void IndentLine(TextDocument document, DocumentLine line)
4141
string indentation = document.GetText(indentationSegment);
4242
// copy indentation to line
4343
indentationSegment = TextUtilities.GetWhitespaceAfter(document, line.Offset);
44-
document.Replace(indentationSegment, indentation);
44+
document.Replace(indentationSegment.Offset, indentation.Length, indentation,
45+
OffsetChangeMappingType.RemoveAndInsert);
46+
// OffsetChangeMappingType.RemoveAndInsert guarantees the caret moves behind the new indentation.
4547
}
4648
}
4749

0 commit comments

Comments
 (0)