Skip to content

Commit 029dd11

Browse files
committed
Improved fix #40 to avoid changes in behaviour of GetPrevCaretPosition()
1 parent 6053a63 commit 029dd11

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

ICSharpCode.AvalonEdit/Editing/CaretNavigationCommandHandler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ internal static TextViewPosition GetNewCaretPosition(TextView textView, TextView
213213
switch (direction) {
214214
case CaretMovementType.CharLeft:
215215
desiredXPos = double.NaN;
216+
// do not move caret to previous line in virtual space
217+
if (caretPosition.VisualColumn == 0 && enableVirtualSpace)
218+
return caretPosition;
216219
return GetPrevCaretPosition(textView, caretPosition, visualLine, CaretPositioningMode.Normal, enableVirtualSpace);
217220
case CaretMovementType.Backspace:
218221
desiredXPos = double.NaN;
@@ -295,8 +298,6 @@ static TextViewPosition GetPrevCaretPosition(TextView textView, TextViewPosition
295298
if (pos >= 0) {
296299
return visualLine.GetTextViewPosition(pos);
297300
} else {
298-
if(enableVirtualSpace && mode == CaretPositioningMode.Normal)
299-
return caretPosition;
300301
// move to end of previous line
301302
DocumentLine previousDocumentLine = visualLine.FirstDocumentLine.PreviousLine;
302303
if (previousDocumentLine != null) {

0 commit comments

Comments
 (0)