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:
Alekhya 2020-06-05 11:34:16 -07:00 committed by GitHub
parent 6adb47c447
commit c01b76e098
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -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;
}

View File

@ -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))