Skip to content

Commit

Permalink
Fix #17068
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Feb 20, 2018
1 parent aacec92 commit ed0e903
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
import { LocalExtensionType, IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { InstallVSIXAction } from 'vs/workbench/parts/extensions/electron-browser/extensionsActions';
import { ExtensionsInput } from 'vs/workbench/parts/extensions/common/extensionsInput';
import { ExtensionsListView, InstalledExtensionsView, RecommendedExtensionsView, WorkspaceRecommendedExtensionsView } from './extensionsViews';
import { ExtensionsListView, InstalledExtensionsView, RecommendedExtensionsView, WorkspaceRecommendedExtensionsView, BuiltInExtensionsView } from './extensionsViews';
import { OpenGlobalSettingsAction } from 'vs/workbench/parts/preferences/browser/preferencesActions';
import { IProgressService } from 'vs/platform/progress/common/progress';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
Expand Down Expand Up @@ -64,6 +64,7 @@ interface SearchInputEvent extends Event {
const NonEmptyWorkspaceContext = new RawContextKey<boolean>('nonEmptyWorkspace', false);
const SearchExtensionsContext = new RawContextKey<boolean>('searchExtensions', false);
const SearchInstalledExtensionsContext = new RawContextKey<boolean>('searchInstalledExtensions', false);
const SearchBuiltInExtensionsContext = new RawContextKey<boolean>('searchBuiltInExtensions', false);
const RecommendedExtensionsContext = new RawContextKey<boolean>('recommendedExtensions', false);
const DefaultRecommendedExtensionsContext = new RawContextKey<boolean>('defaultRecommendedExtensions', false);

Expand All @@ -73,6 +74,7 @@ export class ExtensionsViewlet extends PersistentViewsViewlet implements IExtens
private nonEmptyWorkspaceContextKey: IContextKey<boolean>;
private searchExtensionsContextKey: IContextKey<boolean>;
private searchInstalledExtensionsContextKey: IContextKey<boolean>;
private searchBuiltInExtensionsContextKey: IContextKey<boolean>;
private recommendedExtensionsContextKey: IContextKey<boolean>;
private defaultRecommendedExtensionsContextKey: IContextKey<boolean>;

Expand Down Expand Up @@ -109,6 +111,7 @@ export class ExtensionsViewlet extends PersistentViewsViewlet implements IExtens
this.nonEmptyWorkspaceContextKey = NonEmptyWorkspaceContext.bindTo(contextKeyService);
this.searchExtensionsContextKey = SearchExtensionsContext.bindTo(contextKeyService);
this.searchInstalledExtensionsContextKey = SearchInstalledExtensionsContext.bindTo(contextKeyService);
this.searchBuiltInExtensionsContextKey = SearchBuiltInExtensionsContext.bindTo(contextKeyService);
this.recommendedExtensionsContextKey = RecommendedExtensionsContext.bindTo(contextKeyService);
this.defaultRecommendedExtensionsContextKey = DefaultRecommendedExtensionsContext.bindTo(contextKeyService);
this.defaultRecommendedExtensionsContextKey.set(!this.configurationService.getValue<boolean>(ShowRecommendationsOnlyOnDemandKey));
Expand All @@ -130,6 +133,7 @@ export class ExtensionsViewlet extends PersistentViewsViewlet implements IExtens
viewDescriptors.push(this.createMarketPlaceExtensionsListViewDescriptor());
viewDescriptors.push(this.createInstalledExtensionsListViewDescriptor());
viewDescriptors.push(this.createSearchInstalledExtensionsListViewDescriptor());
viewDescriptors.push(this.createSearchBuiltInExtensionsListViewDescriptor());
viewDescriptors.push(this.createDefaultRecommendedExtensionsListViewDescriptor());
viewDescriptors.push(this.createOtherRecommendedExtensionsListViewDescriptor());
viewDescriptors.push(this.createWorkspaceRecommendedExtensionsListViewDescriptor());
Expand All @@ -142,7 +146,7 @@ export class ExtensionsViewlet extends PersistentViewsViewlet implements IExtens
name: localize('marketPlace', "Marketplace"),
location: ViewLocation.Extensions,
ctor: ExtensionsListView,
when: ContextKeyExpr.and(ContextKeyExpr.has('searchExtensions'), ContextKeyExpr.not('searchInstalledExtensions'), ContextKeyExpr.not('recommendedExtensions')),
when: ContextKeyExpr.and(ContextKeyExpr.has('searchExtensions'), ContextKeyExpr.not('searchInstalledExtensions'), ContextKeyExpr.not('searchBuiltInExtensions'), ContextKeyExpr.not('recommendedExtensions')),
weight: 100
};
}
Expand Down Expand Up @@ -207,6 +211,17 @@ export class ExtensionsViewlet extends PersistentViewsViewlet implements IExtens
};
}

private createSearchBuiltInExtensionsListViewDescriptor(): IViewDescriptor {
return {
id: 'extensions.builtInExtensionsList',
name: localize('builtInExtensions', "Built-In"),
location: ViewLocation.Extensions,
ctor: BuiltInExtensionsView,
when: ContextKeyExpr.has('searchBuiltInExtensions'),
weight: 100
};
}

async create(parent: Builder): TPromise<void> {
parent.addClass('extensions-viewlet');
this.root = parent.getHTMLElement();
Expand Down Expand Up @@ -336,6 +351,7 @@ export class ExtensionsViewlet extends PersistentViewsViewlet implements IExtens
const value = this.searchBox.value || '';
this.searchExtensionsContextKey.set(!!value);
this.searchInstalledExtensionsContextKey.set(InstalledExtensionsView.isInsalledExtensionsQuery(value));
this.searchBuiltInExtensionsContextKey.set(ExtensionsListView.isBuiltInExtensionsQuery(value));
this.recommendedExtensionsContextKey.set(ExtensionsListView.isRecommendedExtensionsQuery(value));
this.nonEmptyWorkspaceContextKey.set(this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,18 @@ export class InstalledExtensionsView extends ExtensionsListView {
}
}

export class BuiltInExtensionsView extends ExtensionsListView {

async show(query: string): TPromise<IPagedModel<IExtension>> {
if (!ExtensionsListView.isBuiltInExtensionsQuery(query)) {
return super.show(query);
}
let searchBuiltInQuery = '@builtin';
searchBuiltInQuery = query ? searchBuiltInQuery + ' ' + query : searchBuiltInQuery;
return super.show(searchBuiltInQuery);
}
}

export class RecommendedExtensionsView extends ExtensionsListView {

async show(query: string): TPromise<IPagedModel<IExtension>> {
Expand Down

0 comments on commit ed0e903

Please sign in to comment.