Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@alekhyareddy28
Copy link
Contributor

Summary of the Pull Request

  • On typing vim, Vim Diff was showing up as the first result and instead of Vim.
  • This was happening because we assign a score to the results which is the max matching score of it's name, description and the executable name.
  • However, since all of them had the same executable name vim.exe all the results were getting the same score.

PR Checklist

Detailed Description of the Pull Request / Additional comments

  • The score is increased by 10 when there is an exact match in the name of the search result.

Validation Steps Performed

  • Tests added.
  • Manually validated.
    image
    image

@alekhyareddy28 alekhyareddy28 requested a review from a team May 19, 2020 20:25
@alekhyareddy28 alekhyareddy28 added the Product-PowerToys Run Improved app launch PT Run (Win+R) Window label May 19, 2020
@alekhyareddy28 alekhyareddy28 changed the title Increases the score for Exact matches in the Name of the Application [launcher] - Increase the score for Exact matches in the Name of the Application May 19, 2020
}
}

// To increase the score of an exact match
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It would be better to use a variable or constant here to have self documenting code. eg.

var bonusForExactMatch = 10; 
score += bonusForExactMatch; 

{
// When, Given
// Arrange
string queryString = "vim";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be data driven for other test cases.

eg.


[TestCase("vim",  "vim", "ignoreDescription", "ignore.exe", "vim diff", "ignoreDescription", "ignore.exe")]
public void WhenMultipleResults_NameWithExactMatch_ShouldHaveGreatestScore(string query, string firstName, string firstDescription, string firstExecutableName, string secondName, string secondDescription, string secondExecutableName); 

var secondExecutableNameMatch = matcher.FuzzyMatch(queryString, secondExecutableName).RawScore;

var firstScore = new[] { firstNameMatch, firstDescriptionMatch, firstExecutableNameMatch }.Max();
var secondScore = new[] { secondNameMatch, secondDescriptionMatch, secondExecutableNameMatch }.Max();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clarification] DescriptionMatch, ExecutableNameMatch will have the same score in both first and second cases and would be ignored by the max operation. Is it required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree. The reason I did it is to emulate the way scoring is done in the code for Win32 Applications. Rather than just comparing the names, which have the max value, I also wanted to show that even though the exe has the same name as the query string, it would still order the results correctly and not affect the scoring, ie. the one with the exact match would have a higher score. However, for clarity, I shall rename it to ignore.exe as suggested by Ryan.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!! Thanks!

@alekhyareddy28 alekhyareddy28 merged commit f07d37c into microsoft:master May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-PowerToys Run Improved app launch PT Run (Win+R) Window

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants