The logic of the vscode custom link jump cannot open the link

Viewed 463

enter image description here

I found two related APIs, go to define and custom editor, but so far testing go to define doesn't seem to work for markdown links (of known type), maybe go to define doesn't support blocking links and supports code level jumping?

The code is as follows

  vscode.languages.registerDefinitionProvider(
    {
      scheme: 'file',
      language: 'markdown',
      pattern: 'edit-*.md',
    },
    new JoplinMarkdownProvider(),
  )
  
export class JoplinMarkdownProvider implements DefinitionProvider {
  provideDefinition(
    document: TextDocument,
    position: Position,
    token: CancellationToken,
  ): ProviderResult<Definition | DefinitionLink[]> {
    console.log('provideDefinition: ', document, position, token)
    return undefined
  }
}

Update, registerDefinitionProvider can intercept clicks, but the returned Uri cannot be opened

For example, https://github.com/ will cause an error when opening

Unable to open'': Unable to resolve resource https://github.com/.

In addition, the query part of the custom schema link will be escaped

The shape is like vscode://rxliuli.joplin-vscode-plugin/open?id=03c8b00ed350410baf41c33daddf3005 => vscode://rxliuli.joplin-vscode-plugin/open?id%3D03c8b00ed350410baf41c33daddf3005

It will also report an error

Unable to open'open': Unable to resolve text model content for resource vscode://rxliuli.joplin-vscode-plugin/open?id%3D03c8b00ed350410baf41c33daddf3005.

The specific error code is at: https://github.com/rxliuli/joplin-vscode-plugin/blob/12854b05da7901a8655f69c90b65f56b67acc73f/src/extension.ts#L147

enter image description here

ref link: https://github.com/Microsoft/vscode/issues/8466

0 Answers
Related