-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for File explorer not showing up and multiple notepads #3969
Fix for File explorer not showing up and multiple notepads #3969
Conversation
…dedupFileExplorer
Probably unrelated to the PR, but I just noticed that start menu search doesn't actually find shortcuts on the desktop. I tried creating a shortcut to an unindexed file on desktop and Start menu doesn't find it but PT Run does. |
|
||
public int GetHashCode(Win32 obj) | ||
{ | ||
return obj.FullPath.GetHashCode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The equal function takes all three variables into account but hashing doesn't. So comparison using hashing and equal would produce different results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Used exor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think exor will ensure uniqueness for hashing. Swapping name and executable name will give false on using Equal
but true on comparing hash codes because exor is commutative operation.
You can use something like below snippet which has a very low probability of being equal(which seems to be standard practice as per this post):
final int prime = 31;
int result = 1;
for( String s : strings )
{
result = result * prime + s.hashCode();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified it as you suggested.
What will happen if two shortcuts only difference in the start parameter for the linked app? |
Yes, the lnkResolved paths would be different then. The .lnk files contain information about the object that they are pointing to and also the arguments that must be passed to that object. Since they differ in their arguments, they would be different shortcuts as they do different things. Hope this clarifies your question. Ref - https://docs.microsoft.com/en-us/windows/win32/shell/links?redirectedfrom=MSDN#link-files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…#3969) * reverted the dedup code, file explorer shows up but so do duplicates * Fixed file explorer and dedup * Formatting * Added tests for all the cases * Formatting * Tests * take name and exe into consideration while calculating hash * unique primes while calculating hash code (cherry picked from commit 8cddd59)
* Add resource only when it is not already present (#3842) (cherry picked from commit d2dfbff) * Take space into consideration while calculating the first matched index (#3874) (cherry picked from commit a8d67a1) * Fix for File explorer not showing up and multiple notepads (#3969) * reverted the dedup code, file explorer shows up but so do duplicates * Fixed file explorer and dedup * Formatting * Added tests for all the cases * Formatting * Tests * take name and exe into consideration while calculating hash * unique primes while calculating hash code (cherry picked from commit 8cddd59)
Summary of the Pull Request
This PR fixes two issues, namely File Explorer not showing up and multiple notepads showing up due to multiple shortcut files in different locations.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Changes made in this PR are -
File Explorer
not showing up because they are lnk files without a resolvedPath.LnkResolvedPath
was not sufficient because shortcuts in different locations have different lnkResolved paths (as mentioned in this comment - PowerToys run shows Notepad en Notepad++ twice #3180 (comment)). Therefore, using the condition that if two applications have the same name, same executable name and same FullPath, they are qualified as the same item.Validation Steps Performed