Repository: vscode
Issue: Open files in new window BUT reveal (existing window) if already open
Labels: feature-request,workbench-editors,workbench-window

<!-- ⚠️⚠️ 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

<!-- 🪓 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.2.1

Steps to Reproduce:

1. In the settings, set
```javascript
"workbench.editor.revealIfOpen": true,
"window.openFilesInNewWindow": "on",
```
2. Double-click on a file associated with VSCode in the Finder (i.e. OS file browser)
3. File should be opened in a new Window (do not close that window)
4. Double-click on the same file in the Finder
5. Bug:
    - **Expected** behaviour: The  already opened Window should be revealed
    - **Actual** behaviour: The file is opened again in another Window

I would consider this a bug as the behaviour ignores `"workbench.editor.revealIfOpen": true,`. I know (so we do not need to discuss that) that there are two concepts: Window and Workbench. That is, I assume that `workbench.editor.revealIfOpen` only effects the behaviour when files are opened from the Explorer view within VSCode, while `window.openFilesInNewWindow` only effects the behaviour when files are opened from outside of VSCode -- and from this point of view the actual behaviour would be correct. So you may give this report another label *feature request* for a new setting **`"window.revealIfOpen": "on"`**.

There are some related issues:
- ["workbench.editor.revealIfOpen": true Not Work When "window.openFilesInNewWindow": "on"](https://github.com/microsoft/vscode/issues/108839)
- And some more specific issues (which are also not solved as far as I understand the problems):
    - [New window.openFilesInNewWindow option: onlyIfOutsideOpenFolders](https://github.com/microsoft/vscode/issues/47215)
    - [Files are not in same folder being opened in new window](https://github.com/microsoft/vscode/issues/60663)

Note: I'm well aware of the possibility of just setting 
```javascript
"window.openFilesInNewWindow": "off",
```
But in that case, all files are just opened in the same Window (in a new tab). Since I usually open (software project) folders, I do not want other, completely unrelated files, to be opened in that window as well.

I'm a little bit surprised to not find more complains about this behaviour, as it has some consequences:
- I cannot use VScode as my default editor for arbitrary files AND as my (kind of ) IDE, since it would open all the files in one single window (this would be the case with `"window.openFilesInNewWindow": "off"`) -- but hey, I want to use multiple windows!
- I have often opened files accidentally in two Windows. Since the files are not synchronised, I have already lost my work since I saved the wrong file (or I have two versions of the file with different content as I mixed up the windows). This is the case for `"window.openFilesInNewWindow": "on"`

I have added a prototype with the expected behaviour. The diff is visible here:
https://github.com/jpilgrim/vscode/compare/main...jpilgrim:vscode:proto212425?diff=split&w=
I could create a PR from this, maybe with some hints of what to improve.