-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Implement plugin API to get workspace folder by file URI #3718
Conversation
@@ -63,13 +63,13 @@ export class WorkspaceMainImpl implements WorkspaceMain { | |||
|
|||
notifyWorkspaceFoldersChanged(): void { | |||
if (this.roots && this.roots.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not part of your change - this.roots
won't be null or undefined, and therefore checking it is not necessary :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elaihau Thanks for the review,
I'm going to open another PR where this checking is removed.
return uri; | ||
} | ||
|
||
if (this.matchPaths(resourcePath, folderPath) && (!workspaceFolder || folderPath.length > workspaceFolder.uri.toString().length)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may go with something like this:
if (folderPath.startsWith(resourcePath) && (!workspaceFolder || folderPath.length > workspaceFolder.uri.toString().length)) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmorhun thanks for review
startsWith
doesn't fit here, because in this case file /home/user/project_2/src/main.js
matches the workspace folder /home/user/project
, which is not correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, you may ensure the trailing slash for resourcePath
.
But up to you, I do not force)
const resourcePathCrumbs = resourcePath.split('/'); | ||
const folderPathCrumbs = folderPath.split('/'); | ||
|
||
for (let i = 0; i < folderPathCrumbs.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benoitf thanks!
updating PR
Signed-off-by: Oleksii Kurinnyi <[email protected]>
9772557
to
f370b26
Compare
fix #3647
Signed-off-by: Oleksii Kurinnyi [email protected]