Repository: vscode
Issue: VSCode forces file type associations on macos
Labels: install-update,macos,under-discussion

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: Yes/No

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->
- VS Code Version: 1.89.1
- OS Version: macOS 14.5

Steps to Reproduce:

1. Install VSCode on macos

Expected:
File type associations are opt-in

Actual:
All code files now open with vscode

This is a continuation of #8687 and #51252, but those issues were auto-locked, so continuing the discussion here.

The current recommendation in those issues is to uninstall VSCode.
That's not a great solution but appears to be the only solution.

I'm filing this issue because I found another workaround and wanted to share with other users: manually editing the `Info.plist` to remove `CFBundleDocumentTypes` / `CFBundleTypeExtensions`.

In short:

1. Make a backup

    ```bash
    cp /Applications/Visual\ Studio\ Code.app/Contents/Info.plist /Applications/Visual\ Studio\ Code.app/Contents/Info.plist.backup
    ```

2. Edit `Info.plist`

    ```bash
    vim /Applications/Visual\ Studio\ Code.app/Contents/Info.plist
    ```

3.  Remove all or specific CFBundleTypeExtensions entries
    For deleting the entries remove everything between two `dict` tags, e.g. delete this to remove the `.h` association

    ```xml
    <dict>
      <key>CFBundleTypeExtensions</key>
      <array>
        <string>h</string>
      </array>
      <key>CFBundleTypeIconFile</key>
      <string>c.icns</string>
      <key>CFBundleTypeName</key>
      <string>C header file</string>
      <key>CFBundleTypeOSTypes</key>
      <array>
        <string>TEXT</string>
        <string>utxt</string>
        <string>TUTX</string>
        <string>****</string>
      </array>
      <key>CFBundleTypeRole</key>
      <string>Editor</string>
    </dict>
    ```

4. Save the updated `Info.plist`

5. Resign the application so you can open it

    ```bash
    codesign --force --deep --sign - /Applications/Visual\ Studio\ Code.app
    ```

6. Force launch services to re-register the application

    ```bash
    /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister -f /Applications/Visual\ Studio\ Code.app
    ```