Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Fix workspace path when multiProjectSetup is enabled #759

Merged
merged 12 commits into from
Apr 17, 2020

Conversation

jannickj
Copy link
Contributor

@jannickj jannickj commented Apr 5, 2020

When enableMultiProjectSetup=true the following bugs will be fixed

  • Fix a minor bug where workspace folder was stripped from short-circuit check
  • Use correct pathing format (Fixes pathing for windows)
  • Fix document selector for windows. (windows wouldn't trigger rls hover/actions)
  • Fix cargo build as it would previously point to the root folder (pointed out by @jli in Handle cases when the outer workspace is not a rust project #419).

The branch has been tested on windows 10 & ubuntu 18.04

Will fix #713

@jannickj
Copy link
Contributor Author

jannickj commented Apr 5, 2020

There seems to be build server problem but I don't think it's related to my branch. @nrc / @Xanewok is that an incorrect assumption?

@jannickj jannickj force-pushed the fix-pathing-for-windows branch from c9edfdf to 7445b96 Compare April 5, 2020 22:55
@jannickj
Copy link
Contributor Author

jannickj commented Apr 5, 2020

Applied the security fixes, just to get a building branch :), I can remove them if you'd rather do it yourself

@jannickj jannickj changed the title Fix pathing for windows when multiProjectSetup is enabled Fix workspace path when multiProjectSetup is enabled Apr 13, 2020
@Xanewok
Copy link
Member

Xanewok commented Apr 16, 2020

Sorry for taking so long. Would you mind rebasing against master again? It'd be great to also have some kind of a regression test for this :)

@Xanewok
Copy link
Member

Xanewok commented Apr 16, 2020

Applied the security fixes, just to get a building branch :), I can remove them if you'd rather do it yourself

Just did that in the meantime, so it'd be good to skip the relevant commits as well.

src/extension.ts Outdated
@@ -90,7 +90,7 @@ function whenOpeningTextDocument(
return;
}

const folderPath = folder.uri.toString();
const folderPath = folder.uri.path;
Copy link
Member

Choose a reason for hiding this comment

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

Does this change give us anything? I feel like we shouldn't use unix-only path if there's not a clear reason; If we should, then we ideally need to somehow document the rationale as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it was just to make hashing identical across systems. I can't remember if it was actually necessary (probably not, so I'll remove it)

jannickj added 10 commits April 16, 2020 21:07
parse obviously only takes URIs meaning it should be `file:///[path]`

using the file command does that as well as fixing from windows format to file uri format.
Only when applying `**` at both ends does it pick it up, shouldn't really affect anyone, given it's still using the full path for matching.
@jannickj jannickj force-pushed the fix-pathing-for-windows branch from 2cb4974 to 12378b1 Compare April 16, 2020 19:08
src/extension.ts Outdated
@@ -208,8 +208,9 @@ class ClientWorkspace {
};

const pattern = this.config.multiProjectEnabled
? `${this.folder.uri.path}/**`
? `**${this.folder.uri.path}/**`
Copy link
Member

Choose a reason for hiding this comment

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

So I'm still wondering about this change... What exactly is the output for both .path and .fsPath and why do we need to prefix that with a wildcard?

Is the wildcard supposed to make the pattern drive-letter-agnostic, e.g. it'd match both C:\Some\Path and D:\Some\Path with a **/some/path/** pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right that's a really good point.

for fsPath it's what you would expect just standard operative system paths
windows: c:\Some\Path
linux: /some/path

path is what is interesting (it's basically the path part of a FILE uri):
windows: /c:/Some/Path with the file uri: file:///c:/Some/Path
linux: /Some/Path with the file uri: file:///Some/Path

Now the pattern matcher uses file uri paths for matching, my guess is they wanted to have a OS agnostic pattern matcher.

The ** is because windows puts something else infront of the files when matching and I have no clue what however the only way to get around it was ** which will catch it.

Copy link
Contributor Author

@jannickj jannickj Apr 16, 2020

Choose a reason for hiding this comment

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

Maybe a better solution would be to only apply this for windows

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for clarifying! What do you mean by something else? Do you mean like c%3A (which is percent-encoded c:)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I meant they put something [something]/c:/... I don't know what that something is and I couldn't figure it out, I thought it was fine however but I understand wanting to fix it the correct way :).

Copy link
Member

Choose a reason for hiding this comment

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

So I did some digging around vscode and vscode-languageserver-node and it seems this should also accept RelativePattern, which encapsulates better what we want to achieve. The typings, however, only accept string, so I'd be fine landing this as-is :)

@jannickj jannickj force-pushed the fix-pathing-for-windows branch from 3a6466d to 65480c5 Compare April 16, 2020 21:35
@Xanewok
Copy link
Member

Xanewok commented Apr 17, 2020

Thank you! I don't want to block this PR further, really appreciate your time and effort to land these fixes 🙇

@Xanewok Xanewok merged commit c3d5421 into rust-lang:master Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RLS fails to start in multi-project setup on non-OS drive
2 participants