问题描述
VSCode 似乎总是记住我的会话并重新打开我上次使用它时打开的文件和/或项目.在提供文件或文件夹的情况下从命令行运行它时,它的行为显然是正确的,但是当从任务栏快捷方式打开时,我希望它默认为空环境.
VSCode always seems to remember my session and reopen the files and/or project that were open the last time I used it. It obviously behaves correctly when running it from the command line with a file or folder supplied, but when opening from a task bar shortcut, I'd like it to default to an empty environment.
有什么办法可以改变这种行为吗?
Is there any way to change this behavior?
推荐答案
您也可以进入您的设置并使用以下内容:
You can also go into your settings and use the following:
当您关闭编辑器时,它不会重新打开您正在处理的文件夹.其他选项是 one
(默认)和 all
.
which will not reopen the folders you were working on when you closed the editor. The other options are one
(the default) and all
.
编辑 2017-11-09:
该选项现已在最新版本中更改.
The option is now changed in latest versions.
"window.restoreWindows": "none"
编辑 2018-09-12:
与此相关的另一个设置是 hotExit
设置.相关问题的this回答中对此进行了讨论.为防止重新打开和记住未保存的文件,您可以将其设置为:
Another setting related to this is the hotExit
setting. This has been discussed in this answer to a related question. To prevent reopening and remembering unsaved files, you can set this to:
"files.hotExit": "off"
但是从我所做的测试来看,当 window.restoreWindows
设置设置为 none
时,这是不需要的.我还没有测试所有可能的组合,所以 YMMV.
But from the test I've made, when the window.restoreWindows
setting is set to none
, this is not needed. I haven't tested every possible combination, so YMMV.
要回答评论中的问题,要编辑设置,您必须打开设置文件.可以在此处找到一些文档(至少在我写这篇文章的日期).
And to answer a question in the comments, to edit the settings, you have to open the settings file. Some documentation can be found here (at least on the date I am writing this).
这篇关于Visual Studio Code 总是重新打开以前的文件或文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!