From ca0e7d7874c7ec83baa8805a8f879b57b9bbfc68 Mon Sep 17 00:00:00 2001 From: Marco Gavelli Date: Sat, 12 Feb 2022 19:48:11 +0100 Subject: [PATCH 1/2] Do not consider lexicographical order for jumpstring --- src/Files/BaseLayout.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Files/BaseLayout.cs b/src/Files/BaseLayout.cs index 9b46ec3338d5..6b94793cd691 100644 --- a/src/Files/BaseLayout.cs +++ b/src/Files/BaseLayout.cs @@ -179,8 +179,7 @@ public string JumpString // starting with the same letter if (value.Length == 1 && previouslySelectedItem != null) { - // Try to select item lexicographically bigger than the previous item - jumpedToItem = candidateItems.FirstOrDefault(f => f.ItemName.CompareTo(previouslySelectedItem.ItemName) > 0); + jumpedToItem = candidateItems.SkipWhile(x => x != previouslySelectedItem).Skip(1).FirstOrDefault(); } if (jumpedToItem == null) { From f1b4f186f9984764bc73ad5079fa2636bdce8f5e Mon Sep 17 00:00:00 2001 From: Marco Gavelli Date: Sat, 12 Feb 2022 20:13:56 +0100 Subject: [PATCH 2/2] Find matching items after currently selected item --- src/Files/BaseLayout.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Files/BaseLayout.cs b/src/Files/BaseLayout.cs index 6b94793cd691..3e66c4a1d6ac 100644 --- a/src/Files/BaseLayout.cs +++ b/src/Files/BaseLayout.cs @@ -167,22 +167,27 @@ public string JumpString ListedItem jumpedToItem = null; ListedItem previouslySelectedItem = null; - // Use FilesAndFolders because only displayed entries should be jumped to - IEnumerable 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) { - jumpedToItem = candidateItems.SkipWhile(x => x != previouslySelectedItem).Skip(1).FirstOrDefault(); + // Use FilesAndFolders because only displayed entries should be jumped to + IEnumerable 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 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(); }