Skip to content

Fix: Fixed issue where archives didn't 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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marcofranzen99
Copy link
Contributor

Resolved / Related Issues

Steps used to test these changes

  1. Set the default app for the '.zip' file extension to Files
  2. Open a '.zip' file using Files
  3. Verify that the archive opens in the same tab, not a new one

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

@Josh65-2201
Copy link
Member

Works for me

Copy link
Contributor

@Copilot Copilot AI left a 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();
Copy link
Preview

Copilot AI Aug 4, 2025

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();

Suggested change
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);
Copy link
Preview

Copilot AI Aug 4, 2025

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.

Suggested change
return (await GetUwpFileAssociations(filename)).FirstOrDefault() ?? GetDesktopFileAssociation(filename);
var desktopAssociation = GetDesktopFileAssociation(filename);
return desktopAssociation ?? (await GetUwpFileAssociations(filename)).FirstOrDefault();

Copilot uses AI. Check for mistakes.

@yaira2 yaira2 changed the title Fix: Fixed bug where archive did not open in existing tab Fix: Fixed issue where archives didn't open in existing tab Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Archives should open in the same tab not a new one
3 participants