mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
[Launcher][WindowWalker]Show all open windows with action keyword (#23307)
This commit is contained in:
parent
67ae9b0376
commit
1f307ba2f0
@ -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>
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user