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

Fix Windows by handling Url paths correctly. #136

Closed
wants to merge 2 commits into from

Conversation

hauserx
Copy link
Contributor

@hauserx hauserx commented Dec 2, 2024

Previous implementation was using Url.path() where it should use Url.to_file_path()

It caused errors like:

"Error: `file:///C:/work/bazel_plain/sample.bzl` could not be converted back to a URL\n"

More: cameron-martin/bazel-lsp#62

The Url.path() is usually "/" + path to file which works fine as file path under unix-like systems, but breaks under Windows, where it can be e.g. "/c:/some/file". See
https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#syntax

Switched to using Url.to_file_path() which represents actual file path.

In the process:

  • Enabled back Windows tests that at least for my machine started passing;
  • In validate() function not converting from Url to LspUrl and back, just returning to client Url passed in the request.

Previous implementation was mixing Url paths with file paths.

It caused errors like:

"Error: `file:///C:/work/bazel_plain/sample.bzl` could not be converted back to a URL\n"

More: cameron-martin/bazel-lsp#62

The Url.path() is usually `"/" + path to file` which works fine as file
path under unix-like systems, but breaks under Windows, where it can be
e.g. "/c:/some/file". See
https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#syntax

Switched to using Url.to_file_path() which
represents actual file path.

In the process:
  - Enabled back Windows tests that at least for my machine started
    passing;
  - In validate() function not converting from Url to LspUrl and back,
    just returning to client Url passed in the request.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 2, 2024
Copy link
Contributor

@ndmitchell ndmitchell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks for this fix, a really nice improvement. One question around the test paths, let me know what seems best here, and then I'll merge it.

starlark_lsp/src/server.rs Outdated Show resolved Hide resolved
@hauserx hauserx requested a review from ndmitchell December 2, 2024 15:37
@facebook-github-bot
Copy link
Contributor

@ndmitchell has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot pushed a commit to facebook/buck2 that referenced this pull request Dec 3, 2024
Summary:
Previous implementation was using `Url.path()` where it should use `Url.to_file_path()`

It caused errors like:

```
"Error: `file:///C:/work/bazel_plain/sample.bzl` could not be converted back to a URL\n"
```

More: cameron-martin/bazel-lsp#62

The `Url.path()` is usually `"/" + path to file` which works fine as file path under unix-like systems, but breaks under Windows, where it can be e.g. `"/c:/some/file"`. See
https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#syntax

Switched to using `Url.to_file_path()` which represents actual file path.

In the process:
  - Enabled back Windows tests that at least for my machine started passing;
  - In validate() function not converting from Url to LspUrl and back, just returning to client Url passed in the request.

X-link: facebook/starlark-rust#136

Reviewed By: KapJI

Differential Revision: D66655476

Pulled By: ndmitchell

fbshipit-source-id: b4590fb27348019424e27ee1d12ffe27d86c6f9f
@facebook-github-bot
Copy link
Contributor

@ndmitchell merged this pull request in 760df74.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants