-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fix: Fixed bug where archive did not open in existing tab #17394
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
base: main
Are you sure you want to change the base?
Fix: Fixed bug where archive did not open in existing tab #17394
Conversation
Works for me |
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.
Pull Request Overview
This PR fixes a bug where ZIP archives would open in a new tab instead of the existing tab when multiple applications were registered for the .zip
file extension. The issue occurred because only the first file association was checked, which might not be the Files app itself.
- Refactored file association checking to examine all registered associations instead of just the first one
- Added new method
GetAllFileAssociationsAsync
to retrieve all file associations for a given file type - Updated the ZIP folder logic to use
Any()
check across all associations to determine if Files app can handle the file
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
ZipStorageFolder.cs | Updated CheckDefaultZipApp to use new method that checks all file associations instead of just the first one |
Win32Helper.Storage.cs | Added GetAllFileAssociationsAsync method and refactored existing association logic into reusable helper methods |
if (checkDesktopFirst) | ||
return GetDesktopAssoc() ?? await GetUwpAssoc(); | ||
return GetDesktopFileAssociation(filename) ?? (await GetUwpFileAssociations(filename)).FirstOrDefault(); |
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.
When checkDesktopFirst
is true, the UWP associations are still retrieved even if a desktop association is found. Consider using a conditional check to avoid the async call when not needed: var desktop = GetDesktopFileAssociation(filename); return desktop ?? (await GetUwpFileAssociations(filename)).FirstOrDefault();
return GetDesktopFileAssociation(filename) ?? (await GetUwpFileAssociations(filename)).FirstOrDefault(); | |
{ | |
var desktop = GetDesktopFileAssociation(filename); | |
if (desktop is not null) | |
return desktop; | |
return (await GetUwpFileAssociations(filename)).FirstOrDefault(); | |
} |
Copilot uses AI. Check for mistakes.
|
||
return await GetUwpAssoc() ?? GetDesktopAssoc(); | ||
return (await GetUwpFileAssociations(filename)).FirstOrDefault() ?? GetDesktopFileAssociation(filename); |
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 UWP associations are retrieved even when a desktop association might be sufficient. Consider checking if only one association is needed and short-circuit the evaluation to avoid unnecessary async operations.
return (await GetUwpFileAssociations(filename)).FirstOrDefault() ?? GetDesktopFileAssociation(filename); | |
var desktopAssociation = GetDesktopFileAssociation(filename); | |
return desktopAssociation ?? (await GetUwpFileAssociations(filename)).FirstOrDefault(); |
Copilot uses AI. Check for mistakes.
Resolved / Related Issues
Steps used to test these changes
Description
On my system, multiple applications were returned for the .zip file extension. The first association returned was not Files, which caused .zip files to open in a new tab instead of the same one.
With this change, all associations are now checked