-
Notifications
You must be signed in to change notification settings - Fork 86
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
The new Uri
type in 0.96.0 is hard to use and have almost no interoperability
#284
Comments
Agree, this is a major regression for Helix. We're going to stick to the older package version for the time being. |
Are there any updates on this? It's understandable that the gluon lang is the main motivation for the existence of this crate. The change broke compatibility and for us it's hard to quickly fix it. P.S. Using String IMO is the best solution. |
I encountered subtle issue when playing with To ensure both extensibility and type safety, Perhaps a #[derive(Serialize, Deseriaize)]
pub struct Uri(String);
#[cfg(feature = "rust-url")]
impl From<Uri> for url::Url { todo!() } |
Yes, because
Would that really be better than the current situation? There would still not be any of the helper methods that the old type provided, and the type would still be different than before so it would still be a breaking change? |
The newtype is unfortunate but it can hopefully be removed with updates to fluent_url eventually. If there are missing conversions please file a PR.
Most is not enough unfortunately, url::Url has incompatibilities with the uris used in the LSP spec so after people found and reported it, it had to go. It is unfortunate that some methods you were relying on were lost in that process but those can at least be restored, whereas the incompatibilities can't be fixed in the url::Url type.
It is not just inconvenicances, the url crate adds extra trailing slashes in some cases e3d0ed2#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759L2820-L2827 which causes changes in behaviour in the LSP.
Not possible,
That seems overall worse to me. With plain strings we get no validations and no convenience methods at all. The current type at least gets us validation and some convenience methods and if the conveniences are not enough we are at least able to add those (either to this crate, or fluent_uri`) to build to something better. If that is not enough at this immediate moment you can always convert to/from strings anyway and do your own handling. |
Could you elaborate so we can check them one-by-one? I assume you are just referring to #261 which I'll explain below. I'm using Turns out there's a divergence of what's "wrong". According to the RFC3986 section 5.2.3 mentioned in that same issue here:
You can also confirm the "correct" behavior from other language's URI/URL implementation, eg. in nodejs 20.12.2: > new URL('foo', new URL('file:https:///no/trailing/slash')).toString()
"file:https:///no/trailing/foo"
> new URL('foo', new URL('file:https:///no/trailing/slash/')).toString()
"file:https:///no/trailing/slash/foo" Though it's kinda unfortunately, it seems manually adding a trailing slash is necessary. In the LSP Spec's recommended implementation
To me, letting user parse it using whatever crate they like directly, is better than parsing to an predetermined type (which some users don't like), serializing to string, and parsing to another type again. The current solution is only better if most users can directly use the
Note that users like me who don't encounter any issue previously, of course, do not report issues. I guess there's a bias here. We only report after the change, like this one.
That's because you missed one slash after the scheme. LSP Spec already mention the format explicitly in here:
For local machine (empty authority), it should be
As I explained above, it seems to match it (and RFC3986) better than
Validation is a good point, though I don't think it's such important considering we have to trust the peer (either server or client) anyway. Also I don't see convenience methods on
It does not look convenient to me. I agree |
@Marwes May be it's possible to parameterize the module with the URL type. I.e. have a feature flag in the module. You could define a type alias and fill it depending on the the feature values. It will at least allow to postpone migration to different url type for your users. |
This reverts URI changes made in #12928 while keeping the perf goodies in tact. We should keep an eye out for gluon-lang/lsp-types#284 Fixes: #13135 Fixes: #13131 Release Notes: - N/A
Yeah I'm also finding this very painful. I don't have a high opinion of the |
Hello all! We have also been unable to upgrade in the Gleam compiler due to lost functionality. Thank you. |
(We're also holding up the update in Slint) |
Same in the LS for Cairo language. |
We've ended up forking the crate (https://github.com/helix-editor/helix/tree/master/helix-lsp-types) but we also plan to make some changes to the fork to better work with the editor internals. |
Same here, holding back from upgrading since the new URI container does not seem to:
|
In #282, we changed the default URI type from
url::Url
tofluent_uri::Uri
. Despitefluent_uri
is several order of magnitude less used (and maybe less tested?) thanurl
, it is also hard to use in the context of LSP servers and clients.lsp_types::Uri
andfluent_uri::Uri
(and also the popularurl::Url
), makinglsp_types::Uri
a standalone type which can only be constructed by parsing a literal string throughFromStr
, which is costly and suffers from escaping traps (also see (2)).file:https://
paths, plusuntitled:
dangling files.url::Url
has convenientUrl::to_file_path
andUrl::from_file_path
for error-resistant conversions. Butfluent_uri
does not provide any relevant methods, and we can only serializing and parsing the path again. Non-UTF-8 and other URL-special characters (#
,?
and etc) should also be carefully handled by the user..join
need some extra steps to work properly, but the crate migration makes it worse:fluent_uri
does not providejoin
at all. The same use-case in that issue will now need to serialize, concatenate and parse again, plus all escaping work mentioned in (2).I suggest to either:
Url
, warn user thatjoin
ing directory URLs should take extra cares. There are only few places that URLs refer to directories rather than files.String
, fully transferring the URL handling logic to downstream users.Either of these approaches would provide better usability and interoperability of URLs from and into LSP protocol uses.
The text was updated successfully, but these errors were encountered: