Skip to content

Editor hover: markdown links should use their own custom scheme #119786

Closed

Description

Steps to Reproduce:

  1. Set "enable-browser-code-loading": "bypassHeatCheck" in ~/argv.json and restart
  2. Clone https://github.com/svsool/vscode-memo
  3. yarn
  4. comment out the line that reads Image preview is currently not supported
  5. Run
  6. open a markdown document with a reference to a PNG in the workspace
  7. retype it as memo notation (e.g. [[images/1_54/macOS-universal-download.png]])
  8. hover over it

=> 🐛 it looks like the resulting image tag uses file protocol and not vscode-file protocol:

image

We need to make sure to use the FileAccess utility to properly convert to a URL that the browser can handle.

Slightly related: Robo (@deepak1556) expressed some interest that the generated HTML from markdown uses a custom scheme so that we can distinguish markdown content from our core content. I had to push a34297a now as a workaround.

Activity

  1. added
    bugIssue identified by VS Code Team member as probable bug
    sandboxRunning VSCode in a node-free environment
    on Mar 24, 2021
  2. deepak1556 commented on Mar 24, 2021

    @deepak1556
    Collaborator

    To clarify, I am proposing to keep vscode-file only deal with resources for the core, we create a separate scheme (ex: vscode-hover) to load resources for the hover html. That way we can keep the restrictions around vscode-file stricter and additionally there is no added cost to having multiple schemes in an app, offering cleaner separation for resource loading.

  3. changed the title [-]Editor hover: markdown links are `file://` based even when `vscode-file` is enabled[/-] [+]Editor hover: markdown links should use their own custom scheme[/+] on Mar 25, 2021
  4. bpasero commented on Mar 25, 2021

    @bpasero
    ContributorAuthor

    After looking a bit closer into what the extension does, I realised that the extension is actually returning file:// URIs as hover contents from here:

    https://github.com/svsool/vscode-memo/blob/5dc4fe035b7c4474d29c6cd24afd33f5e13a1a6e/src/features/ReferenceHoverProvider.ts#L56

    As such, we probably just take the contents as is and rely on the fact that we currently still support to embedd file URIs for rendering.

    But going forward this will not be possible anymore, because once we set our origin to vscode-file://, Chrome disallows any file:// URIs to be loaded.

    I think we almost have to detect absolute URIs that are file based and rewrite them to a custom scheme like Deepak suggests to resolve this going forward.

  5. added
    debtCode quality issues
    and removed
    bugIssue identified by VS Code Team member as probable bug
    on Mar 25, 2021
  6. jrieken commented on Mar 25, 2021

    @jrieken
    Contributor

    We already use the FileAccess-util for uris that have been transformed and it should be easy to use them for all, tho I am unsure how a unified scheme can be achieved because some need the special "this is from a remote" scheme already

  7. jrieken commented on Mar 25, 2021

    @jrieken
    Contributor

    // roblourens unsure what the snippet below is for but it will be broken once we don't use the file-scheme anymore

    const hrefAsUri = URI.parse(href);
    if (options.baseUrl && hrefAsUri.scheme === Schemas.file) { // absolute or relative local path, or file: uri
    href = resolvePath(options.baseUrl, href).toString();
    }

  8. 22 remaining items

  9. LuquinhasSG commented on Aug 25, 2021

    @LuquinhasSG

    I migrated from Vs Code to Vs Code Insiders in build 1.60 with all extensions updated and the problem remains.

    image
    image

  10. jrieken commented on Aug 26, 2021

    @jrieken
    Contributor

    This has likely regressed with 1888070 (which undoes the original fix). Matt Bierner (@mjbvz) I am leaving this up to you since you did the inital fix

  11. mjbvz commented on Aug 26, 2021

    @mjbvz
    Contributor

    Mistakenly checked in a revert of the original fix while fixing another bug. Should be fixed again now. Just tested with Flutter and confirmed the icons show up

  12. locked and limited conversation to collaborators on Oct 10, 2021
  13. added 2 commits that reference this issue on Oct 4, 2025
    863eb4d
    6d29204
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugdebtCode quality issueseditor-hoverEditor mouse hoverinsiders-releasedPatch has been released in VS Code InsiderssandboxRunning VSCode in a node-free environmentverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions