mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
do not change storage when previewing. Fixes #129051
This commit is contained in:
parent
45a5a62228
commit
48c9fd1130
|
@ -9,7 +9,7 @@ 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, CATEGORIES } from 'vs/workbench/common/actions';
|
||||
import { IWorkbenchThemeService, IWorkbenchTheme } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
import { IWorkbenchThemeService, IWorkbenchTheme, ThemeSettingTarget } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
import { VIEWLET_ID, IExtensionsViewPaneContainer } from 'vs/workbench/contrib/extensions/common/extensions';
|
||||
import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
|
@ -20,7 +20,6 @@ import { ColorScheme } from 'vs/platform/theme/common/theme';
|
|||
import { colorThemeSchemaId } from 'vs/workbench/services/themes/common/colorThemeSchema';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { IQuickInputService, QuickPickInput } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { DEFAULT_PRODUCT_ICON_THEME_ID } from 'vs/workbench/services/themes/browser/productIconThemeData';
|
||||
|
||||
export class SelectColorThemeAction extends Action {
|
||||
|
@ -59,8 +58,8 @@ export class SelectColorThemeAction extends Action {
|
|||
selectThemeTimeout = window.setTimeout(() => {
|
||||
selectThemeTimeout = undefined;
|
||||
const themeId = theme && theme.id !== undefined ? theme.id : currentTheme.id;
|
||||
|
||||
this.themeService.setColorTheme(themeId, applyTheme ? 'auto' : undefined).then(undefined,
|
||||
console.log(`setColorTheme apply: ` + applyTheme);
|
||||
this.themeService.setColorTheme(themeId, applyTheme ? 'auto' : 'preview').then(undefined,
|
||||
err => {
|
||||
onUnexpectedError(err);
|
||||
this.themeService.setColorTheme(currentTheme.id, undefined);
|
||||
|
@ -119,7 +118,7 @@ abstract class AbstractIconThemeAction extends Action {
|
|||
protected abstract get placeholderMessage(): string;
|
||||
protected abstract get marketplaceTag(): string;
|
||||
|
||||
protected abstract setTheme(id: string, settingsTarget: ConfigurationTarget | undefined | 'auto'): Promise<any>;
|
||||
protected abstract setTheme(id: string, settingsTarget: ThemeSettingTarget): Promise<any>;
|
||||
|
||||
protected pick(themes: IWorkbenchTheme[], currentTheme: IWorkbenchTheme) {
|
||||
let picks: QuickPickInput<ThemeItem>[] = [this.builtInEntry];
|
||||
|
@ -137,7 +136,7 @@ abstract class AbstractIconThemeAction extends Action {
|
|||
selectThemeTimeout = window.setTimeout(() => {
|
||||
selectThemeTimeout = undefined;
|
||||
const themeId = theme && theme.id !== undefined ? theme.id : currentTheme.id;
|
||||
this.setTheme(themeId, applyTheme ? 'auto' : undefined).then(undefined,
|
||||
this.setTheme(themeId, applyTheme ? 'auto' : 'preview').then(undefined,
|
||||
err => {
|
||||
onUnexpectedError(err);
|
||||
this.setTheme(currentTheme.id, undefined);
|
||||
|
@ -199,7 +198,7 @@ class SelectFileIconThemeAction extends AbstractIconThemeAction {
|
|||
protected installMessage = localize('installIconThemes', "Install Additional File Icon Themes...");
|
||||
protected placeholderMessage = localize('themes.selectIconTheme', "Select File Icon Theme");
|
||||
protected marketplaceTag = 'tag:icon-theme';
|
||||
protected setTheme(id: string, settingsTarget: ConfigurationTarget | undefined | 'auto') {
|
||||
protected setTheme(id: string, settingsTarget: ThemeSettingTarget) {
|
||||
return this.themeService.setFileIconTheme(id, settingsTarget);
|
||||
}
|
||||
|
||||
|
@ -230,7 +229,7 @@ class SelectProductIconThemeAction extends AbstractIconThemeAction {
|
|||
protected installMessage = localize('installProductIconThemes', "Install Additional Product Icon Themes...");
|
||||
protected placeholderMessage = localize('themes.selectProductIconTheme', "Select Product Icon Theme");
|
||||
protected marketplaceTag = 'tag:product-icon-theme';
|
||||
protected setTheme(id: string, settingsTarget: ConfigurationTarget | undefined | 'auto') {
|
||||
protected setTheme(id: string, settingsTarget: ThemeSettingTarget) {
|
||||
return this.themeService.setProductIconTheme(id, settingsTarget);
|
||||
}
|
||||
|
||||
|
|
|
@ -420,6 +420,9 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
|
|||
return Promise.resolve(null);
|
||||
}
|
||||
if (themeId === this.currentColorTheme.id && this.currentColorTheme.isLoaded) {
|
||||
if (settingsTarget !== 'preview') {
|
||||
this.currentColorTheme.toStorage(this.storageService);
|
||||
}
|
||||
return this.settings.setColorTheme(this.currentColorTheme, settingsTarget);
|
||||
}
|
||||
|
||||
|
@ -503,7 +506,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
|
|||
this.onColorThemeChange.fire(this.currentColorTheme);
|
||||
|
||||
// remember theme data for a quick restore
|
||||
if (newTheme.isLoaded) {
|
||||
if (newTheme.isLoaded && settingsTarget !== 'preview') {
|
||||
newTheme.toStorage(this.storageService);
|
||||
}
|
||||
|
||||
|
@ -558,23 +561,23 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
|
|||
public async setFileIconTheme(iconTheme: string | undefined, settingsTarget: ThemeSettingTarget): Promise<IWorkbenchFileIconTheme> {
|
||||
return this.fileIconThemeSequencer.queue(async () => {
|
||||
iconTheme = iconTheme || '';
|
||||
if (iconTheme === this.currentFileIconTheme.id && this.currentFileIconTheme.isLoaded) {
|
||||
await this.settings.setFileIconTheme(this.currentFileIconTheme, settingsTarget);
|
||||
return this.currentFileIconTheme;
|
||||
if (iconTheme !== this.currentFileIconTheme.id || !this.currentFileIconTheme.isLoaded) {
|
||||
|
||||
const newThemeData = this.fileIconThemeRegistry.findThemeById(iconTheme) || FileIconThemeData.noIconTheme;
|
||||
await newThemeData.ensureLoaded(this.fileService);
|
||||
|
||||
this.applyAndSetFileIconTheme(newThemeData); // updates this.currentFileIconTheme
|
||||
}
|
||||
|
||||
const newThemeData = this.fileIconThemeRegistry.findThemeById(iconTheme) || FileIconThemeData.noIconTheme;
|
||||
await newThemeData.ensureLoaded(this.fileService);
|
||||
|
||||
this.applyAndSetFileIconTheme(newThemeData);
|
||||
const themeData = this.currentFileIconTheme;
|
||||
|
||||
// remember theme data for a quick restore
|
||||
if (newThemeData.isLoaded && (!newThemeData.location || !getRemoteAuthority(newThemeData.location))) {
|
||||
newThemeData.toStorage(this.storageService);
|
||||
if (themeData.isLoaded && settingsTarget !== 'preview' && (!themeData.location || !getRemoteAuthority(themeData.location))) {
|
||||
themeData.toStorage(this.storageService);
|
||||
}
|
||||
await this.settings.setFileIconTheme(this.currentFileIconTheme, settingsTarget);
|
||||
|
||||
return newThemeData;
|
||||
return themeData;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -634,23 +637,21 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
|
|||
public async setProductIconTheme(iconTheme: string | undefined, settingsTarget: ThemeSettingTarget): Promise<IWorkbenchProductIconTheme> {
|
||||
return this.productIconThemeSequencer.queue(async () => {
|
||||
iconTheme = iconTheme || '';
|
||||
if (iconTheme === this.currentProductIconTheme.id && this.currentProductIconTheme.isLoaded) {
|
||||
await this.settings.setProductIconTheme(this.currentProductIconTheme, settingsTarget);
|
||||
return this.currentProductIconTheme;
|
||||
if (iconTheme !== this.currentProductIconTheme.id || !this.currentProductIconTheme.isLoaded) {
|
||||
const newThemeData = this.productIconThemeRegistry.findThemeById(iconTheme) || ProductIconThemeData.defaultTheme;
|
||||
await newThemeData.ensureLoaded(this.fileService, this.logService);
|
||||
|
||||
this.applyAndSetProductIconTheme(newThemeData); // updates this.currentProductIconTheme
|
||||
}
|
||||
|
||||
const newThemeData = this.productIconThemeRegistry.findThemeById(iconTheme) || ProductIconThemeData.defaultTheme;
|
||||
await newThemeData.ensureLoaded(this.fileService, this.logService);
|
||||
|
||||
this.applyAndSetProductIconTheme(newThemeData);
|
||||
const themeData = this.currentProductIconTheme;
|
||||
|
||||
// remember theme data for a quick restore
|
||||
if (newThemeData.isLoaded && (!newThemeData.location || !getRemoteAuthority(newThemeData.location))) {
|
||||
newThemeData.toStorage(this.storageService);
|
||||
if (themeData.isLoaded && settingsTarget !== 'preview' && (!themeData.location || !getRemoteAuthority(themeData.location))) {
|
||||
themeData.toStorage(this.storageService);
|
||||
}
|
||||
await this.settings.setProductIconTheme(this.currentProductIconTheme, settingsTarget);
|
||||
|
||||
return newThemeData;
|
||||
return themeData;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -336,7 +336,7 @@ export class ThemeConfiguration {
|
|||
}
|
||||
|
||||
private async writeConfiguration(key: string, value: any, settingsTarget: ThemeSettingTarget): Promise<void> {
|
||||
if (settingsTarget === undefined) {
|
||||
if (settingsTarget === undefined || settingsTarget === 'preview') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ export interface IWorkbenchProductIconTheme extends IWorkbenchTheme {
|
|||
readonly settingsId: string;
|
||||
}
|
||||
|
||||
export type ThemeSettingTarget = ConfigurationTarget | undefined | 'auto';
|
||||
export type ThemeSettingTarget = ConfigurationTarget | undefined | 'auto' | 'preview';
|
||||
|
||||
|
||||
export interface IWorkbenchThemeService extends IThemeService {
|
||||
|
|
Loading…
Reference in a new issue