mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
[Launcher][WindowWalker]Show all open windows with action keyword (#23307)
This commit is contained in:
committed by
GitHub
parent
67ae9b0376
commit
1f307ba2f0
@@ -101,7 +101,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
|
|||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(SearchText))
|
if (string.IsNullOrWhiteSpace(SearchText))
|
||||||
{
|
{
|
||||||
searchMatches = new List<SearchResult>();
|
searchMatches = AllOpenWindows(snapshotOfOpenWindows);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -117,23 +117,16 @@ namespace Microsoft.Plugin.WindowWalker.Components
|
|||||||
private List<SearchResult> FuzzySearchOpenWindows(List<Window> openWindows)
|
private List<SearchResult> FuzzySearchOpenWindows(List<Window> openWindows)
|
||||||
{
|
{
|
||||||
List<SearchResult> result = new List<SearchResult>();
|
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 window in openWindows)
|
||||||
|
|
||||||
foreach (var searchString in searchStrings)
|
|
||||||
{
|
{
|
||||||
foreach (var window in openWindows)
|
var titleMatch = FuzzyMatching.FindBestFuzzyMatch(window.Title, searchStrings.SearchText);
|
||||||
{
|
var processMatch = FuzzyMatching.FindBestFuzzyMatch(window.Process.Name, searchStrings.SearchText);
|
||||||
var titleMatch = FuzzyMatching.FindBestFuzzyMatch(window.Title, searchString.SearchText);
|
|
||||||
var processMatch = FuzzyMatching.FindBestFuzzyMatch(window.Process.Name, searchString.SearchText);
|
|
||||||
|
|
||||||
if ((titleMatch.Count != 0 || processMatch.Count != 0) &&
|
if ((titleMatch.Count != 0 || processMatch.Count != 0) && window.Title.Length != 0)
|
||||||
window.Title.Length != 0)
|
{
|
||||||
{
|
result.Add(new SearchResult(window, titleMatch, processMatch, searchStrings.SearchType));
|
||||||
var temp = new SearchResult(window, titleMatch, processMatch, searchString.SearchType);
|
|
||||||
result.Add(temp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,6 +135,26 @@ namespace Microsoft.Plugin.WindowWalker.Components
|
|||||||
return result;
|
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>
|
/// <summary>
|
||||||
/// Event args for a window list update event
|
/// Event args for a window list update event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -80,6 +80,18 @@ namespace Microsoft.Plugin.WindowWalker.Components
|
|||||||
CalculateScore();
|
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>
|
/// <summary>
|
||||||
/// Calculates the score for how closely this window matches the search string
|
/// Calculates the score for how closely this window matches the search string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user