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

Support icon resource fetch on LSP protocol, multiple content types. #3585

Merged
merged 4 commits into from
Feb 17, 2022

Conversation

sdedic
Copy link
Member

@sdedic sdedic commented Feb 10, 2022

Originally, the TreeView in (vscode) LSP client fetched node information and it got icon resource bits encoded in data: URI. To make the payload smaller, both the LSP client and server implemented a cache: server sent only the entire icon data only the 1st time with an unique id, and sent only that id afterwards.

This PR only sends image URI, and lets the client to ask, if necessary, for the resource bits. The client may substitute the images from its local resources and never ask the server.

Icons that provide their resource URLs are served by reading that URL's contents and base64 encoding to the LSP protocol response. Icons without their own URL (typically from L&Fs) are still painted on a virtual surface, converted to PNG. To avoid situation where the client receives an URI, then the LSP server restarts (crashes), and then the client asks again the PNG bits are stored in the var/cache folder using name hashed from the contents. So even if the server never generated the icon, it can serve the bits from that cache after restart.

The image content type is taken from URL connection - works OK for gif, png, svg (image/svg+xml MIME type). Works OK in vscode client (URIs like data:image/svg+xml;base64,.....). Possibly rebranded images are supported - even a case when a SVG rebrands an original GIF seems to work OK.

There's an additional fix in the vscode client: if a Node disappears after the client receives children response with that node's ID and before it asks for node's info, the client receives an "invalid node" data (id: -1). This PR prevents the node from entering the child list - and if an already existing tree item is updated, this 'invalid' response results in parent's refresh request.

@sdedic sdedic self-assigned this Feb 16, 2022
@sdedic sdedic added API Change [ci] enable extra API related tests LSP [ci] enable Language Server Protocol tests VSCode Extension [ci] enable VSCode Extension tests labels Feb 16, 2022
@sdedic sdedic added this to the NB14 milestone Feb 17, 2022
@sdedic sdedic merged commit 5686358 into apache:master Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Change [ci] enable extra API related tests LSP [ci] enable Language Server Protocol tests VSCode Extension [ci] enable VSCode Extension tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant