|
@@ -1307,13 +1307,13 @@ namespace Avalonia.Controls
|
|
|
{
|
|
|
case Key.Left:
|
|
|
selection = DetectSelection();
|
|
|
- MoveHorizontal(-1, hasWholeWordModifiers, selection);
|
|
|
+ MoveHorizontal(-1, hasWholeWordModifiers, selection, true);
|
|
|
movement = true;
|
|
|
break;
|
|
|
|
|
|
case Key.Right:
|
|
|
selection = DetectSelection();
|
|
|
- MoveHorizontal(1, hasWholeWordModifiers, selection);
|
|
|
+ MoveHorizontal(1, hasWholeWordModifiers, selection, true);
|
|
|
movement = true;
|
|
|
break;
|
|
|
|
|
@@ -1781,7 +1781,7 @@ namespace Avalonia.Controls
|
|
|
/// </summary>
|
|
|
public void Clear() => SetCurrentValue(TextProperty, string.Empty);
|
|
|
|
|
|
- private void MoveHorizontal(int direction, bool wholeWord, bool isSelecting)
|
|
|
+ private void MoveHorizontal(int direction, bool wholeWord, bool isSelecting, bool moveCaretPosition)
|
|
|
{
|
|
|
if (_presenter == null)
|
|
|
{
|
|
@@ -1836,10 +1836,13 @@ namespace Avalonia.Controls
|
|
|
}
|
|
|
|
|
|
SetCurrentValue(SelectionEndProperty, SelectionEnd + offset);
|
|
|
+
|
|
|
+ if (moveCaretPosition)
|
|
|
+ {
|
|
|
+ _presenter.MoveCaretToTextPosition(SelectionEnd);
|
|
|
+ }
|
|
|
|
|
|
- _presenter.MoveCaretToTextPosition(SelectionEnd);
|
|
|
-
|
|
|
- if (!isSelecting)
|
|
|
+ if (!isSelecting && moveCaretPosition)
|
|
|
{
|
|
|
SetCurrentValue(CaretIndexProperty, SelectionEnd);
|
|
|
}
|
|
@@ -1976,7 +1979,7 @@ namespace Avalonia.Controls
|
|
|
|
|
|
_presenter?.MoveCaretToTextPosition(start);
|
|
|
|
|
|
- SetCurrentValue(CaretIndexProperty, start);
|
|
|
+ SetCurrentValue(SelectionStartProperty, start);
|
|
|
|
|
|
ClearSelection();
|
|
|
|
|
@@ -2066,9 +2069,16 @@ namespace Avalonia.Controls
|
|
|
|
|
|
private void SetSelectionForControlBackspace()
|
|
|
{
|
|
|
+ var text = Text ?? string.Empty;
|
|
|
var selectionStart = CaretIndex;
|
|
|
|
|
|
- MoveHorizontal(-1, true, false);
|
|
|
+ MoveHorizontal(-1, true, false, false);
|
|
|
+
|
|
|
+ if (SelectionEnd > 0 &&
|
|
|
+ selectionStart < text.Length && text[selectionStart] == ' ')
|
|
|
+ {
|
|
|
+ SetCurrentValue(SelectionEndProperty, SelectionEnd - 1);
|
|
|
+ }
|
|
|
|
|
|
SetCurrentValue(SelectionStartProperty, selectionStart);
|
|
|
}
|
|
@@ -2083,7 +2093,7 @@ namespace Avalonia.Controls
|
|
|
|
|
|
SetCurrentValue(SelectionStartProperty, CaretIndex);
|
|
|
|
|
|
- MoveHorizontal(1, true, true);
|
|
|
+ MoveHorizontal(1, true, true, false);
|
|
|
|
|
|
if (SelectionEnd < textLength && Text![SelectionEnd] == ' ')
|
|
|
{
|