简体   繁体   English

VSCode 扩展 - 从最近打开的文件中排除 FileSystemProvider 的文件

[英]VSCode Extension - Exclude files of FileSystemProvider from recently opened files

I'm building a vscode extension that proposes changes to the user.我正在构建一个向用户提出更改建议的 vscode 扩展。 The changes are shown in a diff editor, the proposed new content of the file is provided by a FileSystemProvider.更改显示在差异编辑器中,文件的建议新内容由 FileSystemProvider 提供。 The uri used for the scheme file is structured like this:用于方案文件的 uri 结构如下:

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.它甚至不可见,哪个文件是原始文件,哪个文件是我自己的 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.我很确定这是可能的,因为像 GitLens 这样的其他扩展也能够做到这一点,但我不知道有什么区别,也没有在 VSCode 的扩展 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.编辑:我还注意到,当我的扩展程序打开它时,差异没有显示诊断数据,但是当它被 Gitlens 打开时它会显示。 So maybe this is more related to the the diff viewer than the file system provider?所以也许这与 diff 查看器比文件系统提供程序更相关?

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. FileSystemProvider 提供每个文件的不同版本,每个文件由一个查询参数标识。 I'm opening the differences between the original file and the modified in vscode's integrated diff viewer.我在 vscode 的集成差异查看器中打开原始文件和修改后的差异。

Turns out, that I forgot to strip the query parameter, when restoring the original file uri from my custom one.结果是,在从我的自定义文件中恢复原始文件 uri 时,我忘记了删除查询参数。

So vscode actually got a different uri for the original file, each time I compared it with another modified version.所以 vscode 实际上得到了一个不同的原始文件 uri,每次我将它与另一个修改版本进行比较。 Seems like VSCode is able to provide content for file uris with a query parameter, but a fails to provide meta as uris mismatch.似乎 VSCode 能够使用查询参数为文件 uris 提供内容,但是由于 uris 不匹配而无法提供元数据。 Once I removed the query parameter from the uri, this was no longer the case and also diagnostic data was available again.一旦我从 uri 中删除了查询参数,情况就不再如此,并且诊断数据也再次可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM