如何配置VS Code在切换分支时自动关闭删除的文件?

How to configure VS Code to automatically close deleted files when switching branches?

VS Code有没有办法让它在切换分支时自动关闭已删除的文件选项卡?我倾向于在 Tower 中切换分支,当我返回 VS Code 时,一堆已删除的文件仍然显示为打开的选项卡。当我在整个项目中进行重命名时,这会造成混淆,因为它会在此时将文件读回到项目中。

有没有办法解决这个问题,让它在切换分支时关闭已删除的文件选项卡?

我想你想启用:

"workbench.editor.closeOnFileDelete": true,  // default is false

Controls whether editors showing a file that was opened during the session should close automatically when getting deleted or renamed by some other process. Disabling this will keep the editor open on such an event. Note that deleting from within the application will always close the editor and that dirty files will never close to preserve your data.

当在另一个应用程序中删除文件时,这些文件将在 vscode 中立即删除 - 如果这是您想要的,而不仅仅是在切换分支时。