VS Code shows multiple copies of the same file when browsing - visual-studio-code

I keep having this problem that VS Code is showing me multiple copies of the same file in my recently opened section. And I don't know how to get rid of this again 🙃
I've tried enabling workbench.editor.revealIfOpen to no effect.
Any inputs on how to only show one copy of the same file in recently opened?

Turns out this was because the extra copies where opened with a wrong path, it had ./ as a prefix. And vscode treats these as unique copies. It's been fixed for the ReScript extension in this pull request.

Related

VS Code issues on save

This problem is very weird to describe...
Sometimes null characters are added to the end of the open document.
Other times lines are deleted from the end of the document.
I feel like these must be related in a way.
I cannot reliably reproduce the error. But it seems to be connected to when I save the document since it happens much more frequently when autosave is enabled.
Installed extensions are:
Python,
Jupyter,
GithubCopilot,
R
The problem appears as soon as the jupyter extension is enabled.
The funny thing is I have the exact same setup on my desktop with absolutely no problems.
I tried removing visual studio code and the files created in the following folders:
%APPDATA%\Code and %USERPROFILE%.vscode - along with the other extension files like .jupyter.
Reinstalled everything.
Same problem.
You may install the Prettier extension. Prettier would suggest you add a blank line at the end of files so it may prevent cutting the final line in your saved files. I usually use this method.
You can find it on VS Code Marketplace or the documentation.

VSCode Extension - Exclude files of FileSystemProvider from recently opened files

I'm building a vscode extension that proposes changes to the user. The changes are shown in a diff editor, the proposed new content of the file is provided by a FileSystemProvider. The uri used for the scheme file is structured like this:
change://original/path?scheme=file
When I'm openening the toolbar to quickly open files of the current workspace, the file is now enlisted multiple times under the recent files. It isn't even visible, which file is the original and which one is the one provided by my own FileSystemProvider.
How do I avoid my "fake files" being enlisted in the recently opened?
I'm quite sure this is possible, as other extensions like GitLens are able to do this as well, but I can't find out what's the difference and haven't found anything on the documentation of VSCode's Extension API.
Edit: I also noticed, that the diff isn't showing diagnostics data when my extension opens it, but it does when it's opened by Gitlens. So maybe this is more related to the the diff viewer than the file system provider?
As usual, the problem turned out to be of completely different origin. The FileSystemProvider provides different versions of each file, each of which identified by a query parameter. I'm opening the differences between the original file and the modified in vscode's integrated diff viewer.
Turns out, that I forgot to strip the query parameter, when restoring the original file uri from my custom one.
So vscode actually got a different uri for the original file, each time I compared it with another modified version. Seems like VSCode is able to provide content for file uris with a query parameter, but a fails to provide meta as uris mismatch. Once I removed the query parameter from the uri, this was no longer the case and also diagnostic data was available again.

VS Code does not see existing file

Apparently VS Code does not list existing files in files dropdown (Ctrl + P command).
Here is what it shows:
As you can see, the file laravel-2019-09-26.log exists in the directory (left bottom), but not in the files dropdown. After I open this file from the Explorer tree, it starts showing in the dropdown.
Am I doing something wrong or does this happen for everyone? Or is this command supposed to show previously opened files only? If so, what is the way to quickly open any existing file in the workspace?
N.B: I have gone through this related question. No one has mentioned this problem, making me think that this might be specific to my machine.
Edit
For future readers, second answer provided by #michaelze is spot on. VS Code by default does not list files mentioned in .gitignore. You can change this setting by going to Settings panel (File > Preferences > Settings) and typing useIgnoreFiles. This will bring up two boolean settings named Use Global Ignore Files and Use Ignore Files. Turn off these two settings and all workspace files will start showing in the files dropdown. Works correctly as of version 1.38.1.
As those files are .log files, I assume, they are maybe mentioned in the .gitignore file? Maybe this can help you? Visual Studio Code - Automatic exclude based on .gitignore
The list you are seing when pressing CTRL + P is called recently opened. When you open one of the files, it was recently open, so it shows up. The CTRL + P menu also has a files results section that lists actual search results from the files you have in your workspace. None of your .log files are showing up in this section (hence the section is not visible).
The laravel-2019-09-08.log file is also missing from the drop down.
I was wondering if maybe the listing is capped to a certain number of files. Try to be more specific with your search. In my version of VSCode, I can search for files using multiple words. Maybe try searching for "laravel 26" to find the file you are looking for?

Prevent VS Code from opening all files in a folder recursively

I am currently using VS Code on a folder mounted through an SSHFS. The folder has subfolders with many jpg and other image files.
Logging all the files VS Code tries to open reveals it recursively touches all the files (doesn't read the content, just STATs them). This takes very, very long over an SSHfs mount and I can not cancel it without killing the editor (it won't even respond to regular closing).
During this, no files or directories can be opened (inside VSCode) and will show a loading spinner until VS Code has finally had it's way and checked all the files.
This behaviour only recently emerged, I can't pinpoint if any version beyond the current stable version has this behaviour.
I am thinking it might be the new searching engine, but I can't find out which part of the editor is doing it.
It looks like they just posted a fix for your situation:
Slow startup opening a large workspace over the network
you will need vscode v1.32.3

VSCode Filter Problems tab for currently opened file only

I'm looking for a linter feature like-atom that shows the problems by either line, file or project.
Is it possible to filter the Problems tab to only show the errors and warnings in the file being visualized or in the files opened in different tabs instead of from the entire project?
VSCode v.1.23 added the ability to filter the Problems panel by files, see problems view filtering in the release notes.
So you can include (or exclude via the usual glob negation !) only a certain file by entering its name (you may need only a part of it). The filtering is done only within opened tabs however. So you cannot get the entire workspace's problems listed when only some of its files are opened.
The ability to filter the problems panel by the current file has been added to the Insider's Build just recently (#mid-November 2019) so should be in the November 2019 update.. See https://github.com/microsoft/vscode/issues/30038 and https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_41.md#problems-panel
More predefined filters are added to the Problems panel. You can now
filter problems by type and also see problems scoped to the current
active file.
The feature you describe is not currently in VSCode, (I miss it too having got used to it in Eclipse)
There is an open issue with VSCode for this:
Show problems only for currently active file / active line #30038