在 Visual Studio 代码中清除文件内容缓存

Clear file content cache in Visual Studio Code

我的 Visual Studio 代码,在 Windows 机器上,继续向我显示文件的先前内容,即使这个文件已经更新,而 notepad ++ 没有行为同理。

有没有办法以某种方式清理缓存以便每次都能接收到新内容?

我想,我理解正确。您可以按照以下步骤操作。

  1. Ctrl + Shift + P
  2. 键入命令 清除编辑器历史记录
  3. 按回车键

它将解决您的问题。

对于 macOS 上的我来说,以下方法有效:

  1. Cmd + Shift + P
  2. 键入命令 清除搜索历史记录
  3. 按回车键

那么对于搜索结果:

  1. Cmd + Shift + P
  2. 键入命令 清除搜索结果
  3. 按回车键

这对我有用。

.vscode/tasks.json 中添加此任务:

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "label": "clear-editor-history",
      "command": "${command:workbench.action.clearEditorHistory}"
    }
  ]
}

并在启动配置中使用任务 (.vscode/launch)

{
  "version": "0.2.0",
  "configurations": [
    {
      ...
      "preLaunchTask": "clear-editor-history"
      ...
    }
  ]
}