Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static void OnTab(object target, ExecutedRoutedEventArgs args)
TextArea textArea = GetTextArea(target);
if (textArea != null && textArea.Document != null) {
using (textArea.Document.RunUpdate()) {
if (textArea.Selection.IsMultiline) {
if (textArea.Selection.IsMultiline && !textArea.Selection.IsEmpty) {
var segment = textArea.Selection.SurroundingSegment;
DocumentLine start = textArea.Document.GetLineByOffset(segment.Offset);
DocumentLine end = textArea.Document.GetLineByOffset(segment.EndOffset);
Expand Down
5 changes: 4 additions & 1 deletion ICSharpCode.AvalonEdit/Editing/RectangleSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ public override void ReplaceSelectionWithText(string newText)
pos = new TextViewPosition(document.GetLocation(editOffset + firstInsertionLength));
textArea.ClearSelection();
}
textArea.Caret.Position = textArea.TextView.GetPosition(new Point(GetXPos(textArea, pos), textArea.TextView.GetVisualTopByDocumentLine(Math.Max(startLine, endLine)))).GetValueOrDefault();

DocumentLine documentLine = textArea.Document.GetLineByNumber(Math.Max(startLine, endLine));
VisualLine visualLine = textArea.TextView.GetOrConstructVisualLine(documentLine);
textArea.Caret.Position = visualLine.GetTextViewPosition(new Point(GetXPos(textArea, pos), visualLine.VisualTop), EnableVirtualSpace);
}
}

Expand Down