microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.51k stars 29.39k forks source link

Editor history should include editors that open inactive #168477

Open jakrams opened 1 year ago

jakrams commented 1 year ago

Type: Bug

Open an empty vsc instance. Drag and drop two TXT files into VSC. Select one of the files, press F1 and select "Compare Active File With..."

Now in the dropdown it may let you select only 1 file, which may only be the same file that is currently active.

When you switch to the second file and repeat the same thing, it should actually show both files.

After doing a comparison, the list seems to get updated, and trying the same thing on the first file will actually show all open files.

You can also do this with 3 files, in which case one of them should be missing one file to display and the other two work as expected.

VS Code version: Code 1.74.0 (5235c6bb189b60b01b1f49062f4ffa42384f8c91, 2022-12-05T16:38:16.075Z) OS version: Windows_NT x64 10.0.22621 Modes: Sandboxed: No

A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 pythonvspyl392:30443607 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263cf:30335440 pythondataviewer:30285071 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30581797 vsaa593:30376534 pythonvs932:30410667 cppdebug:30492333 vsclangdc:30486549 c4g48928:30535728 dsvsc012:30540252 azure-dev_surveyone:30548225 vsccc:30610678 pyindex848:30577860 nodejswelcome1:30587005 3biah626:30602489 gswce1:30612156 3d0df643:30613357 dbltrim-noruby:30604474 89544117:30613380 fim-prod:30623723 ejf25101:30620729 ```
lramos15 commented 1 year ago

\gifPlease

vscodenpa commented 1 year ago

Thanks for reporting this issue! Unfortunately, it's hard for us to understand what issue you're seeing. Please help us out by providing a screen recording showing exactly what isn't working as expected. While we can work with most standard formats, .gif files are preferred as they are displayed inline on GitHub. You may find https://gifcap.dev helpful as a browser-based gif recording tool.

If the issue depends on keyboard input, you can help us by enabling screencast mode for the recording (Developer: Toggle Screencast Mode in the command palette). Lastly, please attach this file via the GitHub web interface as emailed responses will strip files out from the issue.

Happy coding!

jakrams commented 1 year ago

Recording 2023-06-07 at 11 00 38

This was indeed not trivial to reproduce for a recording and it became quite obvious what the problem is.

Look at the recording. I have a blank vscode instance open. Next to it I have a file with the name "FILE.txt". I then copy that file twice, so I have additional files "FILE - Copy.txt" and "FILE - Copy (2).txt". Then I drag those three files into vscode.

These files (under these names) are all new, vscode has never seen them before in that location (my Desktop).

Now when I press F1 and select "Compare active file with ...", I would expect those three file names to show up. However, only "FILE.txt" is in the list. What is curious, is that there are three additional files in the list "File test 1.txt" to "File test 3.txt". Those are the names that I used before this recording for a test. Those files don't exist anymore.

So from the selected file I can't do the comparison. When I switch to another file "FILE Copy.txt", now that one also shows up in the list, and when I switch to "FILE Copy 2.txt", that one also shows up. Finally, all three are selectable. Though it still shows files that don't exist on disk and were not open in this session and when I finally select one of those, the error message confirms that.

This menu is clearly working on cached data, and it seems to persist this cache between runs. If I were to do this again with the same files, it would now work right away, but if I rename the files, I run into the same problem again.

I know caching is hard, but I think when I open a file in vscode (here: drag multiple files into the editor), their existence should be added to the cache, so that they show up in the menu.

This test was done with:

Version: 1.78.2 (system setup) Commit: b3e4e68a0bc097f0ae7907b217c1119af9e03435 Date: 2023-05-10T14:39:26.248Z Electron: 22.5.2 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Windows_NT x64 10.0.22621 Sandboxed: Yes

vscodenpa commented 1 year ago

Hey @lramos15, this issue might need further attention.

@jakrams, you can help us out by closing this issue if the problem no longer exists, or adding more information.

bpasero commented 1 year ago

This is maybe not the nicest behaviour, but works as intended currently: the compare-with picker seeds from the history of opened editors and not from a list of editors that are currently opened so that you can pick a file that was previously opened. An editor that opens in the background is currently not considered in that list.

Still, we should probably change that assumption also in other contexts: you might want to open multiple files from the command line and in that case the picker of recently opened files would only contain the last one that is visible, not the others. This is slightly unexpected imho.

Code pointer:

https://github.com/microsoft/vscode/blob/ebd67244fb2da33ab078bb2baa96106fda29f336/src/vs/workbench/services/history/browser/historyService.ts#L169-L170

Treating as good feature to keep on the backlog.