gluon-lang / lsp-types

Types for communicating with a language server
MIT License
328 stars 86 forks source link

de-normalizing `Uri` while parsing #276

Open nkitsaini opened 8 months ago

nkitsaini commented 8 months ago

From: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#uri

The URIs below are both valid

file:///c:/project/readme.md
file:///C%3A/project/readme.md

Although not a strict requirement from spec, the reference implementation tries to percent-decode the uri safely: https://github.com/microsoft/vscode-uri/blob/6dec22d7dcc6c63c30343d3a8d56050d0078cb6a/src/uri.ts#L274. If this was supported here, it might make the dealing with Uri a little simpler for the dependent projects.

Currently we use url crate provided serde deserialisation, which doesn't percent-decode the string. As a real life example svelteserver encodes the uri but tsc does not.

Example deserialization using lsp-types lib: Rust Playground Example deserialization using vscode-uri (official implementation): Javascript Playground