Image hover preview shows empty hover window; image never renders (VS Code and Positron)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- typescript, vscode
- Ambito
- tooling
Direzione di ricerca
Start with apps/vscode/src/providers/hover-image.ts and the hover middleware in apps/vscode/src/lsp/client.ts to trace how the local image path becomes hover content. Compare this with the former implementation in apps/lsp/src/service/providers/hover/hover-image.ts and the size-cap context in hover.ts. Done means a local image reliably renders in the hover popup in VS Code and Positron, with the supported image and URL behavior established.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug description
Hovering over a Markdown image reference in a .qmd document (e.g. ) opens a small hover popup, but the image itself never renders. The popup is empty:
"Follow link" works correctly, but there is no image hover. Reproduces in both VS Code and Positron with the Quarto extension.
Steps to reproduce
- Create a
.qmddocument containing an image reference to an existing local file, e.g.. - Hover over the image path/reference.
- Observe: a hover window appears, but no image is displayed.
- Following the link works correctly.
Expected behavior
The hover popup shows a preview of the image.
Actual behavior
A hover window appears, but the image content never loads.
Investigation so far
Image hover is implemented client-side in the extension (apps/vscode/src/providers/hover-image.ts), invoked from the hover middleware in apps/vscode/src/lsp/client.ts. The implementation resolves the local file path correctly, but builds the hover content as raw HTML with a bare filesystem path as the image source:
ts const content = new MarkdownString( `<img src="${imagePath}" ${widthAttrib}/>` ); content.supportHtml = true; content.isTrusted = true;
supportHtml and isTrusted are set, but VS Code's hover Markdown renderer sanitizes HTML and only loads image sources with well-known URI schemes (http(s):, data:, etc.). A bare OS path like /Users/.../plot.png (or C:\... on Windows) is not resolvable, so the popup renders (hence the visible empty hover window) but the image never loads. Note that Uri.file(imagePath) is never used, so even a file:// URI isn't produced.
This is corroborated by the history of this feature. The original server-side implementation (apps/lsp/src/service/providers/hover/hover-image.ts) embedded the image as a base64 data: URI (), a scheme the hover renderer can load, but it was disabled because of a hover content size cap (~75k), per the comment in apps/lsp/src/service/providers/hover/hover.ts. The client-side replacement avoided the size cap by referencing the file directly, but in doing so appears to have lost the ability for the image to render at all.
Additional related issues noticed while investigating
- There is no handling of
http(s)://image URLs. Remote images silently produce no hover at all (the path is joined onto the document directory, failsfs.existsSync, and returnsnull). - Non-PNG images get no width hint (cosmetic;
imageWidth()only handles.png). - Workspace-rooted paths only ever resolve against the first workspace folder.
Possible fix directions
- Inline the image as a
data:URI (as the old server-side code did), with size guarding or downscaling to stay under the hover content cap. - Convert the path to a scheme the hover sanitizer will load (verify whether
file://viaUri.file().toString()works in current VS Code). - Document and confirm the intended behavior and supported image types.
- Run away from home and live in the woods
- Lingua principale
- TypeScript
- Stelle
- 652
- Fork
- 64
- Merge medio
- 8h 45m
- PR unite (30g)
- 36
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di quarto-dev/quarto
-
VS Code extension: `quarto preview` fails when the file path contains parentheses (path not shell-quoted)Forse già presa @Bondrewd-K l’ha presa 2 giorni fa. Apertabug vscode
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
quarto-dev/quarto#1194 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
quarto-dev/quarto#1139 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 90/100
quarto-dev/quarto#1138 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
quarto-dev/quarto#1137 ·
I maintainer di solito rispondono entro 1 giorno
-
Add dependabot?Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
quarto-dev/quarto#1135 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di quarto-dev/quarto
Issue simili
-
Add: Yemen Education SDApertastreams:add
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
apache/rocketmq-dashboard#6872 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
interledger/publisher-tools#931 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ARTPARK-SAHAI-ORG/calibrate-frontend#727 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
fab-geocommuns/RNB-site#539 ·
I maintainer di solito rispondono entro 2 giorni