mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
Set the name(not the description) as the Title of the Result (#4745)
* Added tests to verify that the name is always set as the title and never the description * removed AppType as an argument * refactored code * added comments * localized strings * removed empty constructor * made setsubtitle private * removed the mock Win32 class used for unit testing * removed the UWP tests
This commit is contained in:
@@ -52,6 +52,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
RUN_COMMAND = 3
|
||||
}
|
||||
|
||||
// Function to calculate the score of a result
|
||||
private int Score(string query)
|
||||
{
|
||||
var nameMatch = StringMatcher.FuzzySearch(query, Name);
|
||||
@@ -103,7 +104,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
}
|
||||
|
||||
// Function to set the subtitle based on the Type of application
|
||||
public string SetSubtitle(uint AppType, IPublicAPI api)
|
||||
private string SetSubtitle(IPublicAPI api)
|
||||
{
|
||||
if(AppType == (uint)ApplicationTypes.WIN32_APPLICATION)
|
||||
{
|
||||
@@ -168,7 +169,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
|
||||
var result = new Result
|
||||
{
|
||||
SubTitle = SetSubtitle(AppType, api),
|
||||
SubTitle = SetSubtitle(api),
|
||||
IcoPath = IcoPath,
|
||||
Score = score,
|
||||
ContextData = this,
|
||||
@@ -187,17 +188,9 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
}
|
||||
};
|
||||
|
||||
if (Description.Length >= Name.Length &&
|
||||
Description.Substring(0, Name.Length) == Name)
|
||||
{
|
||||
result.Title = Description;
|
||||
result.TitleHighlightData = StringMatcher.FuzzySearch(query, Description).MatchData;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Title = Name;
|
||||
result.TitleHighlightData = StringMatcher.FuzzySearch(query, Name).MatchData;
|
||||
}
|
||||
// To set the title for the result to always be the name of the application
|
||||
result.Title = Name;
|
||||
result.TitleHighlightData = StringMatcher.FuzzySearch(query, Name).MatchData;
|
||||
|
||||
var toolTipTitle = string.Format("{0} : {1}", api.GetTranslation("powertoys_run_plugin_program_file_name"), result.Title);
|
||||
var toolTipText = string.Format("{0} : {1}", api.GetTranslation("powertoys_run_plugin_program_file_path"), FullPath);
|
||||
|
||||
Reference in New Issue
Block a user