Keep VS Code from creating new directories when file system unmounts

Peter Dong 1 Reputation point
2022-05-02T03:19:27.707+00:00

I am running VS Code on a Windows machine running Ubuntu on WSL 2 that mounts a remote drive from a Linux server using FUSE. This allows me to edit comfortably on VS Code while I run the documents on the server and it generally works great. However, if I am editing and my computer loses its Internet connection briefly, the FUSE mount is lost. If I am in the middle of editing and don't notice, then when I save it, VS Code will see nothing in the directory and create a bunch of directories and save the file locally, which is not what I want to do.

For example, I might be editing a file that is in the mount folder, which is the remote mount. I work on the file mount/somedir/somedir2/someFile.txt. If the Internet connection drops, the remote filesystem is unmounted. If I click Ctrl-s, then VS Code sees only an empty folder called mount. It then creates a somedir directory, then a somedir2 directory, then a someFile.txt file, and saves it there. It is often some time before I catch the problem, and while it is resolvable, I end up with multiple versions of the same file (one on my computer and one on the server) and rationalizing the two is a pain and, if I do it wrong, can end up with me losing work and data (which has happened).

Is there a way to tell VS Code to give an error message when attempting to save a file to a suddenly nonexistent directory, rather than creating it automatically for me? That would make my life and my research group's lives much easier.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,735 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 29,436 Reputation points Microsoft Vendor
    2022-05-02T09:05:54.57+00:00

    Hi @Peter Dong ,

    Thank you for taking time to post this issue in Microsoft Q&A forum.

    Visual Studio Code(VS Code) and Visual Studio IDE(VS) are two different products, and VS Code is currently not supported in the Microsoft Q&A forums, the supported products are listed over here: https://learn.microsoft.com/en-us/answers/products/

    For the related questions(technical support) about VS Code, you can post here: Stack Overflow tagged Visual Studio Code or here: GitHub – Visual Studio Code.

    Thanks for your understanding, have a great day.

    Best Regards,
    Tianyu

    • If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    0 comments No comments