Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source control quickDiffProvider has become experimental, breaking existing usages #175888

Closed
mjcrouch opened this issue Mar 2, 2023 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release scm General SCM compound issues verified Verification succeeded

Comments

@mjcrouch
Copy link
Contributor

mjcrouch commented Mar 2, 2023

Does this issue occur when all extensions are disabled?: N/A - issue with extension API

  • VS Code Version: 1.76.0
  • OS Version: Reproduced on MacOS 13.2.1, Ubuntu 22.10

Steps to Reproduce:

  1. Create an extension using the SourceControl API's quickDiffProvider
  2. Observe that an error is thrown when setting the SourceControl's quickDiffProvider attribute (edit: to an object with a label prop) e.g.
Error: Extension 'mjcrouch.perforce' CANNOT use API proposal: quickDiffProvider.
Its package.json#enabledApiProposals-property declares: [] but NOT quickDiffProvider.
 The missing proposal MUST be added and you must start in extension development mode or use the following command line switch: --enable-proposed-api mjcrouch.perforce

I can see that #169012 adds support for quickDiffProvider from various extensions, however it seems like it has also been marked as experimental within the existing source control usage which breaks my extension that uses the longstanding public API.

@joaomoreno joaomoreno assigned alexr00 and unassigned joaomoreno Mar 2, 2023
@joaomoreno joaomoreno added bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release labels Mar 2, 2023
@joaomoreno
Copy link
Member

joaomoreno commented Mar 2, 2023

This is unfortunate:

  1. The classic Source Control QuickDiffProvider API doesn't have a label prop:

    vscode/src/vscode-dts/vscode.d.ts

    Lines 14259 to 14270 in 8dcf90c

    interface QuickDiffProvider {
    /**
    * Provide a {@link Uri} to the original resource of any given resource uri.
    *
    * @param uri The uri of the resource open in a text editor.
    * @param token A cancellation token.
    * @return A thenable that resolves to uri of the matching original resource.
    */
    provideOriginalResource?(uri: Uri, token: CancellationToken): ProviderResult<Uri>;
    }
  2. New QuickDiffProvider instances have it (but not required 🤔):
    interface QuickDiffProvider {
    label?: string;
    }
    }
  3. So the proposed API check tests against that:
    if (quickDiffProvider?.label) {
    checkProposedApiEnabled(this._extension, 'quickDiffProvider');
    }

@alexr00 since the prop is even optional in the new QuickDiffProvider type, I suggest to just remove the proposed API check in extHostSCM.

Marking as candidate to raise awareness: #175888

@mjcrouch
Copy link
Contributor Author

mjcrouch commented Mar 2, 2023

I see, to clarify my initial post then, must be because my extension uses an object that happens to have a label prop rather than just any usage of the quick diff provider!

@mjcrouch
Copy link
Contributor Author

mjcrouch commented Mar 3, 2023

just a note that I updated my extension - just added a simple object to use as a quickDiffProvider, that wraps around provideOriginalResource and doesn't have a label. This is a simple workaround and resolved the issue for my extension.

This will of course still be an issue for users of other extensions, such as the original slevesque.perforce extension that my extension is forked from, but the info may be useful for others!

@alexr00
Copy link
Member

alexr00 commented Mar 8, 2023

To verify:

  1. Open the source control extension sample from https://github.com/microsoft/vscode-extension-samples/tree/main/source-control-sample
  2. Modify fiddleRepository.ts to have a public string label in the FiddleRepository (https://github.com/microsoft/vscode-extension-samples/blob/d7dd9da34a9849396719408716d468512b5e5abb/source-control-sample/src/fiddleRepository.ts#L25-L26).
  3. npm install and npm run watch
  4. F5 to run the extension
  5. Open the chrome dev tools so you can watch for API proposal errors.
  6. Run the command Open JS Fiddle and go through all the prompt
    a. JSFiddle ID can be anything
    b. Choose the current folder that you have open
    c. Don't delete any files
  7. Verify that you don't get any API proposal errors in the dev tools

@meganrogge meganrogge added the verified Verification succeeded label Mar 8, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release scm General SCM compound issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants