Skip to content
Merged
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
20 changes: 12 additions & 8 deletions src/Files/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,27 @@ public string JumpString
ListedItem jumpedToItem = null;
ListedItem previouslySelectedItem = null;

// Use FilesAndFolders because only displayed entries should be jumped to
IEnumerable<ListedItem> candidateItems = ParentShellPageInstance.FilesystemViewModel.FilesAndFolders.Where(f => f.ItemName.Length >= value.Length && string.Equals(f.ItemName.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase));

if (IsItemSelected)
{
previouslySelectedItem = SelectedItem;
}

// If the user is trying to cycle through items
// starting with the same letter
if (value.Length == 1 && previouslySelectedItem != null)
// Select first matching item after currently selected item
if (previouslySelectedItem != null)
{
// Try to select item lexicographically bigger than the previous item
jumpedToItem = candidateItems.FirstOrDefault(f => f.ItemName.CompareTo(previouslySelectedItem.ItemName) > 0);
// Use FilesAndFolders because only displayed entries should be jumped to
IEnumerable<ListedItem> candidateItems = ParentShellPageInstance.FilesystemViewModel.FilesAndFolders
.SkipWhile(x => x != previouslySelectedItem)
.Skip(value.Length == 1 ? 1 : 0) // User is trying to cycle through items starting with the same letter
.Where(f => f.ItemName.Length >= value.Length && string.Equals(f.ItemName.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase));
jumpedToItem = candidateItems.FirstOrDefault();
}

if (jumpedToItem == null)
{
// Use FilesAndFolders because only displayed entries should be jumped to
IEnumerable<ListedItem> candidateItems = ParentShellPageInstance.FilesystemViewModel.FilesAndFolders
.Where(f => f.ItemName.Length >= value.Length && string.Equals(f.ItemName.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase));
jumpedToItem = candidateItems.FirstOrDefault();
}

Expand Down