Skip to content

Commit

Permalink
Fix: Fixed an issue where selection would get canceled after pressing…
Browse files Browse the repository at this point in the history
… upper arrow key (files-community#13847)
  • Loading branch information
RieBi authored Dec 13, 2023
1 parent 6706117 commit f085a0c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ protected virtual async void RenameTextBox_LostFocus(object sender, RoutedEventA
protected async void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
{
var textBox = (TextBox)sender;
var isShiftPressed = (InteropHelpers.GetKeyState((int)VirtualKey.Shift) & KEY_DOWN_MASK) != 0;

switch (e.Key)
{
case VirtualKey.Escape:
Expand All @@ -300,11 +302,13 @@ protected async void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
e.Handled = true;
break;
case VirtualKey.Up:
textBox.SelectionStart = 0;
if (!isShiftPressed)
textBox.SelectionStart = 0;
e.Handled = true;
break;
case VirtualKey.Down:
textBox.SelectionStart = textBox.Text.Length;
if (!isShiftPressed)
textBox.SelectionStart = textBox.Text.Length;
e.Handled = true;
break;
case VirtualKey.Left:
Expand All @@ -316,7 +320,6 @@ protected async void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
case VirtualKey.Tab:
textBox.LostFocus -= RenameTextBox_LostFocus;

var isShiftPressed = (InteropHelpers.GetKeyState((int)VirtualKey.Shift) & KEY_DOWN_MASK) != 0;
NextRenameIndex = isShiftPressed ? -1 : 1;

if (textBox.Text != OldItemName)
Expand Down

0 comments on commit f085a0c

Please sign in to comment.