mirror of
https://github.com/Microsoft/vscode
synced 2024-10-31 11:34:45 +00:00
Update smoke test (#29096)
This commit is contained in:
parent
1ed580c82a
commit
b9d1534d79
3 changed files with 42 additions and 27 deletions
|
@ -20,6 +20,7 @@ export interface IQuickPickItem {
|
|||
iconClasses?: string[];
|
||||
buttons?: IQuickInputButton[];
|
||||
picked?: boolean;
|
||||
alwaysShow?: boolean;
|
||||
}
|
||||
|
||||
export interface IQuickPickSeparator {
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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';
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue