vscode icon indicating copy to clipboard operation
vscode copied to clipboard

QuickDiffProvider is not refreshable

Open rinrab opened this issue 8 months ago • 6 comments

This problem is related to the quick diff API of the source control integration.

This API suggests us to implement the vscode.QuickDiffProvider interface. However, the thing is that I can't notify Code that the base have been changed.

Use vscode.TextDocumentContentProvider which includes onDidChange property you may say. But it kinda sucks if I return null nor an exception from the content provider which I actually need to in order to prevent quick diff indicators. At least it worked in older versions if I return "" from the provider.

Does this mean I can't disable quick diff for several files during specific period of time. In my case, I don't wanna show diff for unversioned, i.e. untracked files. I think it's gonna be great to have something to prevent quick diff at some point.

Oh, I just realised that I can return the same content as WORKING, but this may work bad, since during an actual change in the editor BASE will remain the same.

What if you allow null result of the content provider or even better quick diff provider so we can prevent quick diff from appearing. Separately, I wanna suggest adding onDidOriginalResourceChanged to the vscode.QuickDiffProvider interface.

What do you think?

rinrab avatar Apr 24 '25 19:04 rinrab

related: I just noticed vscode.proposed.quickDiffProvider.d.ts proposal API

rinrab avatar Apr 24 '25 19:04 rinrab

related: I just noticed vscode.proposed.quickDiffProvider.d.ts proposal API

I guess it doesn't help me a lot, but it still seems good in general

rinrab avatar Apr 24 '25 19:04 rinrab

I see there is several internal stuff for visibility of quick diff providers that may help if api is introduced

rinrab avatar Apr 24 '25 19:04 rinrab

@rinrab, could you please elaborate on your scenario? Are you implementing a source control provider? I am asking since at the moment only source control providers can define a QuickDiffProvider. If getOriginalResource() returns null then the quick diff decoration will not be shown.

lszomoru avatar May 05 '25 09:05 lszomoru

@lszomoru, thank you for your response!

Yes, I'm developing a source control plugin, which also implements a vscode.SourceControl. The quick diff provided is implemented through the scm provider by initialising the scm.quickDiffProvider field.

I see, the getOriginalResource() returning null prevents decorations from appearing. I need this functionality deal with unversioned files which are the case in a source control I'm working with. But, after any operation that changes status of a node between unversioned and versioned I want to notify quick diff whether I want the decorations to show or not.

rinrab avatar May 05 '25 13:05 rinrab

The git extension does just that when "staging/unstaging" a file. We do that through the file system provider that the git extension is implementing. This is the code that "notifies" VS Code core to ask for an updated state of the original resource: https://github.com/microsoft/vscode/blob/6209ba20b441b81f05b8771c5dfda84642a87a10/extensions/git/src/fileSystemProvider.ts#L66-L79

lszomoru avatar May 21 '25 07:05 lszomoru