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

Make ExtensionTipsService multi-root aware #32106

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { localize } from 'vs/nls';
import * as paths from 'vs/base/common/paths';
import { flatten } from 'vs/base/common/arrays';
import { TPromise } from 'vs/base/common/winjs.base';
import { forEach } from 'vs/base/common/collections';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
Expand Down Expand Up @@ -68,16 +68,20 @@ export class ExtensionTipsService implements IExtensionTipsService {
if (!this.contextService.hasWorkspace()) {
return TPromise.as([]);
}
return this.fileService.resolveContent(this.contextService.toResource(paths.join('.vscode', 'extensions.json'))).then(content => { //TODO@Sandeep (https://github.com/Microsoft/vscode/issues/29242)
const extensionsContent = <IExtensionsContent>json.parse(content.value, []);
if (extensionsContent.recommendations) {
const regEx = new RegExp(EXTENSION_IDENTIFIER_PATTERN);
return extensionsContent.recommendations.filter((element, position) => {
return extensionsContent.recommendations.indexOf(element) === position && regEx.test(element);
});
}
return [];
}, err => []);
return TPromise.join(
this.contextService.getWorkspace().roots.map(root =>
this.fileService.resolveContent(root.with({ path: root.path + '/.vscode/extensions.json' })).then(content => {
Copy link
Member

Choose a reason for hiding this comment

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

I would use the old way paths to construct the path. This will make construct the path as per the platform

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would use backslashes on Windows, which is not valid in a URI

Copy link
Member

Choose a reason for hiding this comment

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

That would use backslashes on Windows

True, but it is a valid file path. Creating an URI using URI.file takes care of it
Good thing is it will hide the knowledge of path separators.

const extensionsContent = <IExtensionsContent>json.parse(content.value, []);
if (extensionsContent.recommendations) {
const regEx = new RegExp(EXTENSION_IDENTIFIER_PATTERN);
return extensionsContent.recommendations.filter((element, position) => {
return extensionsContent.recommendations.indexOf(element) === position && regEx.test(element);
});
}
return [];
}).then<string[]>(null, err => [])
)
).then(flatten);
Copy link
Member

Choose a reason for hiding this comment

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

Also needed to de dup

}

getRecommendations(): string[] {
Expand Down