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

Implement plugin API to get workspace folder by file URI #3718

Merged
merged 1 commit into from
Dec 6, 2018

Conversation

akurinnoy
Copy link
Contributor

fix #3647

Signed-off-by: Oleksii Kurinnyi okurinny@redhat.com

@@ -63,13 +63,13 @@ export class WorkspaceMainImpl implements WorkspaceMain {

notifyWorkspaceFoldersChanged(): void {
if (this.roots && this.roots.length) {
Copy link
Contributor

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 :)

Copy link
Contributor Author

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)) {
Copy link
Contributor

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)) {

Copy link
Contributor Author

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.

Copy link
Contributor

@mmorhun mmorhun Dec 5, 2018

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++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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 <okurinny@redhat.com>
@akurinnoy akurinnoy merged commit 7213f4b into eclipse-theia:master Dec 6, 2018
@akurinnoy akurinnoy deleted the get-workspace-folder branch July 30, 2019 11:39
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.

Implement plugin API to get workspace folder by file uri
5 participants