[Launcher][WindowWalker]Show all open windows with action keyword (#23307)

This commit is contained in:
Davide Giacometti 2023-01-26 13:33:12 +01:00 committed by GitHub
parent 67ae9b0376
commit 1f307ba2f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 15 deletions

View File

@ -101,7 +101,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
if (string.IsNullOrWhiteSpace(SearchText))
{
searchMatches = new List<SearchResult>();
searchMatches = AllOpenWindows(snapshotOfOpenWindows);
}
else
{
@ -117,23 +117,16 @@ namespace Microsoft.Plugin.WindowWalker.Components
private List<SearchResult> FuzzySearchOpenWindows(List<Window> openWindows)
{
List<SearchResult> result = new List<SearchResult>();
List<SearchString> searchStrings = new List<SearchString>();
var searchStrings = new SearchString(searchText, SearchResult.SearchType.Fuzzy);
searchStrings.Add(new SearchString(searchText, SearchResult.SearchType.Fuzzy));
foreach (var searchString in searchStrings)
foreach (var window in openWindows)
{
foreach (var window in openWindows)
{
var titleMatch = FuzzyMatching.FindBestFuzzyMatch(window.Title, searchString.SearchText);
var processMatch = FuzzyMatching.FindBestFuzzyMatch(window.Process.Name, searchString.SearchText);
var titleMatch = FuzzyMatching.FindBestFuzzyMatch(window.Title, searchStrings.SearchText);
var processMatch = FuzzyMatching.FindBestFuzzyMatch(window.Process.Name, searchStrings.SearchText);
if ((titleMatch.Count != 0 || processMatch.Count != 0) &&
window.Title.Length != 0)
{
var temp = new SearchResult(window, titleMatch, processMatch, searchString.SearchType);
result.Add(temp);
}
if ((titleMatch.Count != 0 || processMatch.Count != 0) && window.Title.Length != 0)
{
result.Add(new SearchResult(window, titleMatch, processMatch, searchStrings.SearchType));
}
}
@ -142,6 +135,26 @@ namespace Microsoft.Plugin.WindowWalker.Components
return result;
}
/// <summary>
/// Search method that matches all the windows with a title
/// </summary>
/// <param name="openWindows">what windows are open</param>
/// <returns>Returns search results</returns>
private List<SearchResult> AllOpenWindows(List<Window> openWindows)
{
List<SearchResult> result = new List<SearchResult>();
foreach (var window in openWindows)
{
if (window.Title.Length != 0)
{
result.Add(new SearchResult(window));
}
}
return result.OrderBy(w => w.Result.Title).ToList();
}
/// <summary>
/// Event args for a window list update event
/// </summary>

View File

@ -80,6 +80,18 @@ namespace Microsoft.Plugin.WindowWalker.Components
CalculateScore();
}
/// <summary>
/// Initializes a new instance of the <see cref="SearchResult"/> class.
/// </summary>
internal SearchResult(Window window)
{
Result = window;
SearchMatchesInTitle = new List<int>();
SearchMatchesInProcessName = new List<int>();
SearchResultMatchType = SearchType.Empty;
CalculateScore();
}
/// <summary>
/// Calculates the score for how closely this window matches the search string
/// </summary>