mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-28 07:39:49 +08:00
Fix for PWAs and command prompt not showing up as the first result (#4020)
* Added code which increments the score for the app without any arguments * Removed magic number and added var
This commit is contained in:
parent
6adb47c447
commit
c01b76e098
@ -102,6 +102,8 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
// To initialize the app description
|
||||
public String description = String.Empty;
|
||||
|
||||
// Sets to true if the program takes in arguments
|
||||
public bool hasArguments = false;
|
||||
|
||||
// Retrieve the target path using Shell Link
|
||||
public string retrieveTargetPath(string path)
|
||||
@ -125,6 +127,15 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
buffer = new StringBuilder(MAX_PATH);
|
||||
((IShellLinkW)link).GetDescription(buffer, MAX_PATH);
|
||||
description = buffer.ToString();
|
||||
|
||||
StringBuilder argumentBuffer = new StringBuilder(MAX_PATH);
|
||||
((IShellLinkW)link).GetArguments(argumentBuffer, argumentBuffer.Capacity);
|
||||
|
||||
// Set variable to true if the program takes in any arguments
|
||||
if (argumentBuffer.Length != 0)
|
||||
{
|
||||
hasArguments = true;
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
public string Description { get; set; }
|
||||
public bool Valid { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public bool hasArguments { get; set; } = false;
|
||||
public string Location => ParentDirectory;
|
||||
|
||||
private const string ShortcutExtension = "lnk";
|
||||
@ -54,6 +55,12 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!hasArguments)
|
||||
{
|
||||
var noArgumentScoreModifier = 5;
|
||||
score += noArgumentScoreModifier;
|
||||
}
|
||||
|
||||
var result = new Result
|
||||
{
|
||||
SubTitle = "Win32 application",
|
||||
@ -191,6 +198,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
program.LnkResolvedPath = program.FullPath;
|
||||
program.FullPath = Path.GetFullPath(target).ToLower();
|
||||
program.ExecutableName = Path.GetFileName(target);
|
||||
program.hasArguments = _helper.hasArguments;
|
||||
|
||||
var description = _helper.description;
|
||||
if (!string.IsNullOrEmpty(description))
|
||||
|
Loading…
Reference in New Issue
Block a user