Skip to content

Improved reliability of the search experience #6671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 31, 2021
Merged
Show file tree
Hide file tree
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
33 changes: 21 additions & 12 deletions Files/Filesystem/Search/FolderSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@ public class FolderSearch

public EventHandler SearchTick;

private bool IsAQSQuery => Query is not null && (Query.StartsWith("$") || Query.Contains(":"));

private string QueryWithWildcard
{
get
{
if (!string.IsNullOrEmpty(Query) && Query.Contains('.')) // ".docx" -> "*.docx"
{
var split = Query.Split('.');
var leading = string.Join('.', split.SkipLast(1));
var query = $"{leading}*.{split.Last()}";
return $"{query}*";
}
return $"{Query}*";
}
}

public string AQSQuery
{
get
Expand All @@ -56,7 +73,7 @@ public string AQSQuery
}
else
{
return $"System.FileName:\"{Query}\"";
return $"System.FileName:\"{QueryWithWildcard}\"";
}
}
}
Expand Down Expand Up @@ -245,20 +262,12 @@ private async Task AddItemsAsync(string folder, IList<ListedItem> results, Cance
if (workingFolder)
{
await SearchAsync(workingFolder, results, token);
//foreach (var item in await SearchAsync(workingFolder))
//{
// results.Add(item);
//}
hiddenOnlyFromWin32 = true;
hiddenOnlyFromWin32 = (results.Count != 0);
}

if (!hiddenOnlyFromWin32 || UserSettingsService.FilesAndFoldersSettingsService.AreHiddenItemsVisible)
if (!IsAQSQuery && (!hiddenOnlyFromWin32 || UserSettingsService.FilesAndFoldersSettingsService.AreHiddenItemsVisible))
{
await SearchWithWin32Async(folder, hiddenOnlyFromWin32, UsedMaxItemCount - (uint)results.Count, results, token);
//foreach (var item in)
//{
// results.Add(item);
//}
}
}
}
Expand All @@ -269,7 +278,7 @@ private async Task SearchWithWin32Async(string folder, bool hiddenOnly, uint max
(IntPtr hFile, WIN32_FIND_DATA findData) = await Task.Run(() =>
{
int additionalFlags = FIND_FIRST_EX_LARGE_FETCH;
IntPtr hFileTsk = FindFirstFileExFromApp($"{folder}\\*{Query}*.*", FINDEX_INFO_LEVELS.FindExInfoBasic,
IntPtr hFileTsk = FindFirstFileExFromApp($"{folder}\\{QueryWithWildcard}", FINDEX_INFO_LEVELS.FindExInfoBasic,
out WIN32_FIND_DATA findDataTsk, FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, additionalFlags);
return (hFileTsk, findDataTsk);
}).WithTimeoutAsync(TimeSpan.FromSeconds(5));
Expand Down
2 changes: 1 addition & 1 deletion Files/Services/Implementation/FileTagsSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public FileTag GetTagById(string uid)

public IEnumerable<FileTag> GetTagsByName(string tagName)
{
return FileTagList.Where(x => x.TagName.Equals(tagName, StringComparison.OrdinalIgnoreCase));
return FileTagList.Where(x => x.TagName.StartsWith(tagName, StringComparison.OrdinalIgnoreCase));
}
}
}
11 changes: 7 additions & 4 deletions Files/Views/ModernShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,12 @@ private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, Keybo
break;
}

case (false, false, false, true, VirtualKey.F3): //f3
case (true, false, false, true, VirtualKey.F): // ctrl + f
NavToolbarViewModel.SwitchSearchBoxVisibility();
case (false, false, false, _, VirtualKey.F3): //f3
case (true, false, false, _, VirtualKey.F): // ctrl + f
if (tabInstance || CurrentPageType == typeof(WidgetsPage))
{
NavToolbarViewModel.SwitchSearchBoxVisibility();
}
break;

case (true, true, false, true, VirtualKey.N): // ctrl + shift + n, new item
Expand Down Expand Up @@ -1137,7 +1140,7 @@ public class PathBoxItem
public class NavigationParams
{
public string NavPath { get; set; }
public string SelectItem { get; set;}
public string SelectItem { get; set; }
}

public class NavigationArguments
Expand Down