Skip to content

Commit

Permalink
Update smoke test (#29096)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Aug 10, 2018
1 parent 1ed580c commit b9d1534
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/vs/platform/quickinput/common/quickInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface IQuickPickItem {
iconClasses?: string[];
buttons?: IQuickInputButton[];
picked?: boolean;
alwaysShow?: boolean;
}

export interface IQuickPickSeparator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ export class QuickInputList {
element.labelHighlights = undefined;
element.descriptionHighlights = undefined;
element.detailHighlights = undefined;
element.hidden = true;
element.hidden = !element.item.alwaysShow;
}
element.separator = undefined;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
import { Registry } from 'vs/platform/registry/common/platform';
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
import { IQuickOpenService, IPickOpenEntry } from 'vs/platform/quickOpen/common/quickOpen';
import { IWorkbenchThemeService, COLOR_THEME_SETTING, ICON_THEME_SETTING, IColorTheme, IFileIconTheme } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { VIEWLET_ID, IExtensionsViewlet } from 'vs/workbench/parts/extensions/common/extensions';
import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement';
Expand All @@ -27,6 +26,7 @@ import { ConfigurationTarget } from 'vs/platform/configuration/common/configurat
import { LIGHT, DARK, HIGH_CONTRAST } from 'vs/platform/theme/common/themeService';
import { schemaId } from 'vs/workbench/services/themes/common/colorThemeSchema';
import { onUnexpectedError } from 'vs/base/common/errors';
import { IQuickInputService, IQuickPickItem, QuickPickInput } from 'vs/platform/quickinput/common/quickInput';

export class SelectColorThemeAction extends Action {

Expand All @@ -36,7 +36,7 @@ export class SelectColorThemeAction extends Action {
constructor(
id: string,
label: string,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IQuickInputService private quickInputService: IQuickInputService,
@IWorkbenchThemeService private themeService: IWorkbenchThemeService,
@IExtensionGalleryService private extensionGalleryService: IExtensionGalleryService,
@IViewletService private viewletService: IViewletService,
Expand All @@ -49,15 +49,18 @@ export class SelectColorThemeAction extends Action {
return this.themeService.getColorThemes().then(themes => {
const currentTheme = this.themeService.getColorTheme();

const picks: IPickOpenEntry[] = [].concat(
const picks: QuickPickInput[] = [].concat(
toEntries(themes.filter(t => t.type === LIGHT), localize('themes.category.light', "light themes")),
toEntries(themes.filter(t => t.type === DARK), localize('themes.category.dark', "dark themes"), true),
toEntries(themes.filter(t => t.type === HIGH_CONTRAST), localize('themes.category.hc', "high contrast themes"), true),
configurationEntries(this.extensionGalleryService, this.viewletService, 'category:themes', localize('installColorThemes', "Install Additional Color Themes..."))
configurationEntries(this.extensionGalleryService, localize('installColorThemes', "Install Additional Color Themes..."))
);

const selectTheme = (theme, applyTheme: boolean) => {
if (typeof theme.id === 'undefined') { // 'pick in marketplace' entry
if (applyTheme) {
openExtensionViewlet(this.viewletService, 'category:themes');
}
theme = currentTheme;
}
let target = null;
Expand All @@ -75,12 +78,12 @@ export class SelectColorThemeAction extends Action {
};

const placeHolder = localize('themes.selectTheme', "Select Color Theme (Up/Down Keys to Preview)");
const autoFocusIndex = firstIndex(picks, p => p.id === currentTheme.id);
const autoFocusIndex = firstIndex(picks, p => p.type !== 'separator' && p.id === currentTheme.id);
const delayer = new Delayer<void>(100);
const chooseTheme = theme => delayer.trigger(() => selectTheme(theme || currentTheme, true), 0);
const tryTheme = theme => delayer.trigger(() => selectTheme(theme, false));

return this.quickOpenService.pick(picks, { placeHolder, autoFocus: { autoFocusIndex }, onDidFocus: tryTheme })
return this.quickInputService.pick(picks, { placeHolder, activeItem: picks[autoFocusIndex], onDidFocus: tryTheme })
.then(chooseTheme);
});
}
Expand All @@ -94,7 +97,7 @@ class SelectIconThemeAction extends Action {
constructor(
id: string,
label: string,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IQuickInputService private quickInputService: IQuickInputService,
@IWorkbenchThemeService private themeService: IWorkbenchThemeService,
@IExtensionGalleryService private extensionGalleryService: IExtensionGalleryService,
@IViewletService private viewletService: IViewletService,
Expand All @@ -108,14 +111,17 @@ class SelectIconThemeAction extends Action {
return this.themeService.getFileIconThemes().then(themes => {
const currentTheme = this.themeService.getFileIconTheme();

let picks: IPickOpenEntry[] = [{ id: '', label: localize('noIconThemeLabel', 'None'), description: localize('noIconThemeDesc', 'Disable file icons') }];
let picks: QuickPickInput[] = [{ id: '', label: localize('noIconThemeLabel', 'None'), description: localize('noIconThemeDesc', 'Disable file icons') }];
picks = picks.concat(
toEntries(themes),
configurationEntries(this.extensionGalleryService, this.viewletService, 'tag:icon-theme', localize('installIconThemes', "Install Additional File Icon Themes..."))
configurationEntries(this.extensionGalleryService, localize('installIconThemes', "Install Additional File Icon Themes..."))
);

const selectTheme = (theme, applyTheme: boolean) => {
if (typeof theme.id === 'undefined') { // 'pick in marketplace' entry
if (applyTheme) {
openExtensionViewlet(this.viewletService, 'tag:icon-theme');
}
theme = currentTheme;
}
let target = null;
Expand All @@ -132,39 +138,47 @@ class SelectIconThemeAction extends Action {
};

const placeHolder = localize('themes.selectIconTheme', "Select File Icon Theme");
const autoFocusIndex = firstIndex(picks, p => p.id === currentTheme.id);
const autoFocusIndex = firstIndex(picks, p => p.type !== 'separator' && p.id === currentTheme.id);
const delayer = new Delayer<void>(100);
const chooseTheme = theme => delayer.trigger(() => selectTheme(theme || currentTheme, true), 0);
const tryTheme = theme => delayer.trigger(() => selectTheme(theme, false));

return this.quickOpenService.pick(picks, { placeHolder, autoFocus: { autoFocusIndex }, onDidFocus: tryTheme })
return this.quickInputService.pick(picks, { placeHolder, activeItem: picks[autoFocusIndex], onDidFocus: tryTheme })
.then(chooseTheme);
});
}
}

function configurationEntries(extensionGalleryService: IExtensionGalleryService, viewletService: IViewletService, query: string, label: string): IPickOpenEntry[] {
function configurationEntries(extensionGalleryService: IExtensionGalleryService, label: string): QuickPickInput[] {
if (extensionGalleryService.isEnabled()) {
return [{
id: void 0,
label: label,
separator: { border: true },
alwaysShow: true,
run: () => viewletService.openViewlet(VIEWLET_ID, true).then(viewlet => {
(<IExtensionsViewlet>viewlet).search(query);
viewlet.focus();
})
}];
return [
{
type: 'separator',
border: true
},
{
id: void 0,
label: label,
alwaysShow: true,
}
];
}
return [];
}

function openExtensionViewlet(viewletService: IViewletService, query: string) {
return viewletService.openViewlet(VIEWLET_ID, true).then(viewlet => {
(<IExtensionsViewlet>viewlet).search(query);
viewlet.focus();
});
}

function toEntries(themes: (IColorTheme | IFileIconTheme)[], label?: string, border = false) {
const toEntry = theme => <IPickOpenEntry>{ id: theme.id, label: theme.label, description: theme.description };
const sorter = (t1: IColorTheme, t2: IColorTheme) => t1.label.localeCompare(t2.label);
let entries = themes.map(toEntry).sort(sorter);
const toEntry = theme => <IQuickPickItem>{ id: theme.id, label: theme.label, description: theme.description };
const sorter = (t1: IQuickPickItem, t2: IQuickPickItem) => t1.label.localeCompare(t2.label);
let entries: QuickPickInput[] = themes.map(toEntry).sort(sorter);
if (entries.length > 0 && (label || border)) {
entries[0].separator = { label, border };
entries.unshift({ type: 'separator', label, border });
}
return entries;
}
Expand Down

0 comments on commit b9d1534

Please sign in to comment.