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 sourcelink url generation when deterministic paths are used on Windows #878

Merged
merged 1 commit into from
Jan 9, 2022

Conversation

baronfel
Copy link
Contributor

@baronfel baronfel commented Jan 9, 2022

Discovered this while evaluating #875, but deterministic sourcelink paths had a bug on Windows at least with path manipulation. This fixes it, let's see how CI works?

@baronfel
Copy link
Contributor Author

baronfel commented Jan 9, 2022

A worked example:

  • for the Ionide.LanguageServerProtocol package, sourcelink has an entry of "/_/*":"<github url for that repo>".
  • We map that path into a regex for url substitution of the form /_/(.+).
  • When going to definition, we get a url for the source file like D:/_//src/LanguageServerProtocol.fs, but the actual document.Name is /_//src/LanguageServerProtocol.fs
  • Matching that document name against the regex we get a 'source fragment' of the form /src/LanguageServerProtocol.fs
  • We combine this fragment with the github url from the sourcelink document to get a url of the form https://github.com/ionide/LanguageServerProtocol/raw/<git SHA>//src/LanguageServerProtocol.fs
  • The // in the url result makes the Path.Combine for the temp file path bomb out on Windows, so the overall activity fails.

@baronfel baronfel merged commit 88bb1a5 into ionide:main Jan 9, 2022
@baronfel baronfel deleted the fix-sourcelink-determinism branch January 9, 2022 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant