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

Unable to open relative links #397

Closed
rongcuid opened this issue Mar 22, 2021 · 3 comments · Fixed by #400
Closed

Unable to open relative links #397

rongcuid opened this issue Mar 22, 2021 · 3 comments · Fixed by #400

Comments

@rongcuid
Copy link
Contributor

Description

In preview window, when I click on a link to relative file, it does not open (either InEditor or InPreview).

System Information

Version: 1.54.3
Commit: 2b9aebd5354a3629c3aba0a5f5df49f43d6689f8
Date: 2021-03-15T10:55:24.277Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Linux x64 5.8.0-7642-generic

To Reproduce

  1. In a directory, create A.adoc and B.adoc. Fill in random contents.
  2. In A.adoc, create a relative link by:
    • link:B.adoc, or
    • <<B.adoc#>>
  3. Try to click on link in preview window

Any other combination of outfilesuffix or relfilesuffix result in the same behavior.

@rongcuid
Copy link
Contributor Author

OK, I triangulated the problem, but I am unable to solve it due to unfamiliarity with VSCode or TS:

src/features/preview.ts:133, here the extension registers a WebView callback onDidReceiveMessage which handles the link clicking and various other features. However, this closure is never executed. I don't know if it failed to register or something.

@rongcuid
Copy link
Contributor Author

OK, it doesn't make sense. The callback seems to be fine, but nothing in index.ts gets executed. There lies the code to actually send the clickLink events, etc.

@rongcuid
Copy link
Contributor Author

I found the issue:
index.ts:137 supports only file: and vscode-resource: protocol. However, using the Webview debug window, I find that the links are actually vscode-webview-resource: protocol, and seem to follow a different format.

I checked the VSCode Markdown extension, and find that instead of processing inside the index.ts script which is run in Webview, it instead lets the backend resolve the URI. I am working on refactoring this part to do the same. This modification will also allow passthrough, though I am not sure what it may be used for.

For reference:
https://github.com/microsoft/vscode/blob/main/extensions/markdown-language-features/preview-src/index.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant