AnalyticalGraphicsInc / gltf-vscode

This is an extension for Visual Studio Code to add support for editing glTF files.
Apache License 2.0
460 stars 63 forks source link

Ctrl-hover on images URI opens a new tab #92

Closed lexaknyazev closed 3 years ago

lexaknyazev commented 6 years ago
  1. VSCode 1.21.1, plugin 2.1.7.
  2. Open any glTF 2.0 asset that uses textures (e.g. glTF-Sample-Models/2.0/BoxTextured/glTF/BoxTextured.gltf).
  3. Ctrl-hover (without clicking) on image (e.g. /images/0/uri) URI.
  4. A new tab with image appears.

A new tab shouldn't appear without clicking.

najadojo commented 6 years ago

I think this going to be a "won't fix". If you want a hover image just release the Ctrl and you'll get the normal image preview. onDefinition doesn't give any context about how its being used so changing behavior isn't possible. Its actually pretty hacky to get what we have working well as the system is built around navigating and presenting text documents.

lexaknyazev commented 6 years ago

Sorry, I don't quite understand. It's possible to Ctrl-hover over, e.g., Draco pointers and see some values in tool-tips. Ctrl-click opens a full list of values in a new document. Why can't image URIs behave the same way?

najadojo commented 6 years ago

VSCode's onDefinition system provides a document URI and a cursor location and it expects a URI and a cursor location back. For JSON definition this works pretty simply; we use the same URI and find the location of the pointed to object. For data buffers we craft a new data URI which includes information on what accessor is under the cursor. The protocol handler for that data URI transforms the accessor into a new text document and VSCode shows this content where appropriate. For images the same type of data URI is constructed but we can't present text; we need to command VSCode to open a tab and show the image in an HTML page. We had in previous revisions of the extension just returned a URI directly to the image (which is what you see when hovering with out Ctrl). VSCode limits the size of images it will open in this way to 1MB and as you can see with the hover doesn't scale the image so you can see the whole thing in the editor window.

I can open an feature request with VSCode to allow definitions to return an HTML document. With this capability we'd be much more able to handle all the cases as expected.

emackey commented 3 years ago

Can't reproduce this anymore. I think it was fixed upstream.