microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.53k stars 29.39k forks source link

Allow anyone (not just SCM) to hook into quick diff provider #169012

Open alexr00 opened 1 year ago

alexr00 commented 1 year ago

Why this would be useful: https://github.com/microsoft/vscode-pull-request-github/issues/392

We'll also need to determine what should happen when there are multiple quick diff providers on the same range.

alexr00 commented 1 year ago

@laurentlb FYI in case you would also find this useful.

alexr00 commented 1 year ago

Here's what it looks like:

Recording 2023-02-16 at 15 43 06

justanotheranonymoususer commented 1 year ago

Will it also allow to show gutter markers? If yes, perhaps https://github.com/microsoft/vscode/issues/167306 can be implemented with an extension

alexr00 commented 1 year ago

Yes, this shows gutter markers.

eamodio commented 1 year ago

@alexr00 I've tried out this proposal (thrilled about it BTW) and I've run into an issue where it doesn't seem like the quickdiff is removed from the editor properly when disposed. I am currently turning on the feature by calling registerQuickDiffProvider on-demand (in response to a user action) and want to turn it back off when they toggle it back off, but even when disposing the returned disposable it doesn't clear it from the document.

Also minor, but why is there a label both on the registerQuickDiffProvider call and on the provider itself?

eamodio commented 1 year ago

Playing with this some more (in today's insiders), it seems dispose works more reliably, but still not 100%.

alexr00 commented 1 year ago

@eamodio there was a dispose that wasn't happening. It is fixed in insiders, though if you're not seeing it work 100% then I'll need to investigate further.

Also minor, but why is there a label both on the registerQuickDiffProvider call and on the provider itself?

This will likely be deduplicated.

sergei-dyshel commented 1 year ago

Is provideOriginalResource should be called for existing editors at the moment of registration?

I have the following sequence of events (vscode 1.76):

  1. Text editor is showed.
  2. Extension loads and calls registerQuickDiffProvider.
  3. Newly registered quick diff doesn't show.
  4. I close and reopen the editor.
  5. Quick diff is properly displayed in the editor.
eamodio commented 11 months ago

@alexr00 Any chance this could land soon? I would love to get this in.

alexr00 commented 11 months ago

@eamodio do you have any other feedback on the API?

Adding to February to revisit then.

eamodio commented 11 months ago

Not really it seems to work well as is. I have a branch with it implemented for the File Changes annotations in GitLens: https://github.com/gitkraken/vscode-gitlens/tree/feature/gutter-changes

Thanks!

starball5 commented 10 months ago

We'll also need to determine what should happen when there are multiple quick diff providers on the same range.

Related? #196759

alexr00 commented 9 months ago

Moving back to the backlog as we're not going to get to https://github.com/microsoft/vscode/issues/196759 this month.

gjsjohnmurray commented 2 months ago

@alexr00 are there any plans to finalize this API?

alexr00 commented 2 months ago

We don't have a plan to finalize it. Tentatively assigning to October to see if we have time then.

jrieken commented 2 weeks ago