Interface ExternalUriOpener

Handles opening uris to external resources, such as http(s) links.

Extensions can implement an ExternalUriOpener to open http links to a webserver inside of the editor instead of having the link be opened by the web browser.

Currently openers may only be registered for http and https uris.

interface ExternalUriOpener {
    canOpenExternalUri(uri, token): ExternalUriOpenerPriority | Thenable<ExternalUriOpenerPriority>;
    openExternalUri(resolvedUri, ctx, token): void | Thenable<void>;
}

Methods

  • Open a uri.

    This is invoked when:

    • The user clicks a link which does not have an assigned opener. In this case, first canOpenExternalUri is called and if the user selects this opener, then openExternalUri is called.
    • The user sets the default opener for a link in their settings and then visits a link.

    Parameters

    • resolvedUri: Uri

      The uri to open. This uri may have been transformed by port forwarding, so it may not match the original uri passed to canOpenExternalUri. Use ctx.originalUri to check the original uri.

    • ctx: OpenExternalUriContext

      Additional information about the uri being opened.

    • token: CancellationToken

      Cancellation token indicating that opening has been canceled.

    Returns void | Thenable<void>

    Thenable indicating that the opening has completed.