diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/de.xaml b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/de.xaml
index 51ed267560..40200babb8 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/de.xaml
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/de.xaml
@@ -39,6 +39,7 @@
Weblink-Anwendung
Web-Anwendung
Run command
+ Packaged application
Name
Path
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/en.xaml b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/en.xaml
index 8c2a76533c..71a24d774a 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/en.xaml
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/en.xaml
@@ -50,6 +50,8 @@
Internet shortcut application
Web application
Run command
+ Packaged application
Name
Path
+
\ No newline at end of file
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/ja.xaml b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/ja.xaml
index 80296c9fb0..c623a24597 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/ja.xaml
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/ja.xaml
@@ -40,6 +40,7 @@
Internet shortcut application
Web application
Run command
+ Packaged application
Name
Path
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/pl.xaml b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/pl.xaml
index c31f95f985..ef6b3a0d11 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/pl.xaml
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/pl.xaml
@@ -39,6 +39,7 @@
Internet shortcut application
Web application
Run command
+ Packaged application
Name
Path
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/tr.xaml b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/tr.xaml
index 3ddeb60efc..8a3b9b5327 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/tr.xaml
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/tr.xaml
@@ -41,6 +41,7 @@
Internet shortcut application
Web application
Run command
+ Packaged application
Name
Path
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/zh-cn.xaml b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/zh-cn.xaml
index ef4f8ce7f9..6d62b5df9b 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/zh-cn.xaml
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/zh-cn.xaml
@@ -41,6 +41,7 @@
Internet shortcut application
Web application
Run command
+ Packaged application
Name
Path
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/zh-tw.xaml b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/zh-tw.xaml
index c563efcbae..b63b4bf015 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/zh-tw.xaml
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/zh-tw.xaml
@@ -39,6 +39,7 @@
Internet shortcut application
Web application
Run command
+ Packaged application
Name
Path
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/IProgram.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/IProgram.cs
index b5edcb280b..3f8d6270ae 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/IProgram.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/IProgram.cs
@@ -9,6 +9,7 @@ namespace Microsoft.Plugin.Program.Programs
Result Result(string query, IPublicAPI api);
string UniqueIdentifier { get; set; }
string Name { get; }
+ string Description { get; set; }
string Location { get; }
}
}
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs
index ea961247d1..e28220b677 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs
@@ -262,13 +262,20 @@ namespace Microsoft.Plugin.Program.Programs
public string LogoPath { get; set; }
public UWP Package { get; set; }
+ // Function to calculate the score of a result
private int Score(string query)
{
var displayNameMatch = StringMatcher.FuzzySearch(query, DisplayName);
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
var score = new[] { displayNameMatch.Score, descriptionMatch.Score/2 }.Max();
return score;
- }
+ }
+
+ // Function to set the subtitle based on the Type of application
+ private string SetSubtitle(IPublicAPI api)
+ {
+ return api.GetTranslation("powertoys_run_plugin_program_packaged_application");
+ }
public Result Result(string query, IPublicAPI api)
{
@@ -280,7 +287,7 @@ namespace Microsoft.Plugin.Program.Programs
var result = new Result
{
- SubTitle = "Packaged application",
+ SubTitle = SetSubtitle(api),
Icon = Logo,
Score = score,
ContextData = this,
@@ -291,17 +298,10 @@ namespace Microsoft.Plugin.Program.Programs
}
};
- if (Description.Length >= DisplayName.Length &&
- Description.Substring(0, DisplayName.Length) == DisplayName)
- {
- result.Title = Description;
- result.TitleHighlightData = StringMatcher.FuzzySearch(query, Description).MatchData;
- }
- else
- {
- result.Title = DisplayName;
- result.TitleHighlightData = StringMatcher.FuzzySearch(query, DisplayName).MatchData;
- }
+ // To set the title to always be the displayname of the packaged application
+ result.Title = DisplayName;
+ 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"), Package.Location);
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32.cs
index 48444e4956..80796ee4d2 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32.cs
@@ -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);
diff --git a/src/modules/launcher/Wox.Test/Plugins/ProgramPluginTest.cs b/src/modules/launcher/Wox.Test/Plugins/Win32Tests.cs
similarity index 95%
rename from src/modules/launcher/Wox.Test/Plugins/ProgramPluginTest.cs
rename to src/modules/launcher/Wox.Test/Plugins/Win32Tests.cs
index 25d6afe2d8..af5fcf0dfc 100644
--- a/src/modules/launcher/Wox.Test/Plugins/ProgramPluginTest.cs
+++ b/src/modules/launcher/Wox.Test/Plugins/Win32Tests.cs
@@ -12,7 +12,7 @@ using System.IO;
namespace Wox.Test.Plugins
{
[TestFixture]
- public class ProgramPluginTest
+ public class Win32Tests
{
Win32 notepad_appdata = new Win32
{
@@ -138,6 +138,7 @@ namespace Wox.Test.Plugins
Win32 cmder_run_command = new Win32
{
Name = "Cmder",
+ Description = "Cmder: Lovely Console Emulator",
ExecutableName = "Cmder.exe",
FullPath = "c:\\tools\\cmder\\cmder.exe",
LnkResolvedPath = null,
@@ -333,5 +334,21 @@ namespace Wox.Test.Plugins
// the query matches the name (cmd) and is therefore not filtered (case-insensitive)
Assert.IsTrue(cmd_run_command.QueryEqualsNameForRunCommands(query));
}
+
+ [Test]
+ public void Win32Apps_ShouldSetNameAsTitle_WhileCreatingResult()
+ {
+ // Arrange
+ var mock = new Mock();
+ mock.Setup(x => x.GetTranslation(It.IsAny())).Returns(It.IsAny());
+ StringMatcher.Instance = new StringMatcher();
+
+ // Act
+ var result = cmder_run_command.Result("cmder", mock.Object);
+
+ // Assert
+ Assert.IsTrue(result.Title.Equals(cmder_run_command.Name));
+ Assert.IsFalse(result.Title.Equals(cmder_run_command.Description));
+ }
}
}