mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 18:48:33 -05:00
Merge from vscode 8df646d3c5477b02737fc10343fa7cf0cc3f606b
This commit is contained in:
@@ -81,7 +81,7 @@ export class CommandService extends Disposable implements ICommandService {
|
||||
}
|
||||
try {
|
||||
this._onWillExecuteCommand.fire({ commandId: id, args });
|
||||
const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler, ...args]);
|
||||
const result = this._instantiationService.invokeFunction(command.handler, ...args);
|
||||
this._onDidExecuteCommand.fire({ commandId: id, args });
|
||||
return Promise.resolve(result);
|
||||
} catch (err) {
|
||||
@@ -90,4 +90,4 @@ export class CommandService extends Disposable implements ICommandService {
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(ICommandService, CommandService, true);
|
||||
registerSingleton(ICommandService, CommandService, true);
|
||||
|
||||
@@ -339,7 +339,7 @@ export class HistoryService extends Disposable implements IHistoryService {
|
||||
|
||||
const navigateToStackEntry = this.navigationStack[this.navigationStackIndex];
|
||||
|
||||
this.doNavigate(navigateToStackEntry).finally(() => this.navigatingInStack = false);
|
||||
this.doNavigate(navigateToStackEntry).finally(() => { this.navigatingInStack = false; });
|
||||
}
|
||||
|
||||
private doNavigate(location: IStackEntry): Promise<IEditorPane | undefined> {
|
||||
|
||||
@@ -150,31 +150,19 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
|
||||
// update settings schema setting for theme specific settings
|
||||
this.colorThemeRegistry.onDidChange(async event => {
|
||||
updateColorThemeConfigurationSchemas(event.themes);
|
||||
|
||||
const colorThemeSetting = this.settings.colorTheme;
|
||||
if (colorThemeSetting !== this.currentColorTheme.settingsId) {
|
||||
const theme = await this.colorThemeRegistry.findThemeBySettingsId(colorThemeSetting, undefined);
|
||||
if (theme) {
|
||||
this.setColorTheme(theme.id, undefined);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.currentColorTheme.isLoaded) {
|
||||
const themeData = await this.colorThemeRegistry.findThemeById(this.currentColorTheme.id);
|
||||
if (!themeData) {
|
||||
// current theme is no longer available
|
||||
prevColorId = this.currentColorTheme.id;
|
||||
this.setColorTheme(DEFAULT_COLOR_THEME_ID, 'auto');
|
||||
} else {
|
||||
if (this.currentColorTheme.id === DEFAULT_COLOR_THEME_ID && !types.isUndefined(prevColorId) && await this.colorThemeRegistry.findThemeById(prevColorId)) {
|
||||
// restore theme
|
||||
this.setColorTheme(prevColorId, 'auto');
|
||||
prevColorId = undefined;
|
||||
} else if (event.added.some(t => t.settingsId === this.currentColorTheme.settingsId)) {
|
||||
this.reloadCurrentColorTheme();
|
||||
}
|
||||
if (await this.restoreColorTheme()) { // checks if theme from settings exists and is set
|
||||
// restore theme
|
||||
if (this.currentColorTheme.id === DEFAULT_COLOR_THEME_ID && !types.isUndefined(prevColorId) && await this.colorThemeRegistry.findThemeById(prevColorId)) {
|
||||
// restore theme
|
||||
this.setColorTheme(prevColorId, 'auto');
|
||||
prevColorId = undefined;
|
||||
} else if (event.added.some(t => t.settingsId === this.currentColorTheme.settingsId)) {
|
||||
this.reloadCurrentColorTheme();
|
||||
}
|
||||
} else if (event.removed.some(t => t.settingsId === this.currentColorTheme.settingsId)) {
|
||||
// current theme is no longer available
|
||||
prevColorId = this.currentColorTheme.id;
|
||||
this.setColorTheme(DEFAULT_COLOR_THEME_ID, 'auto');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -189,7 +177,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
|
||||
} else if (event.added.some(t => t.settingsId === this.currentFileIconTheme.settingsId)) {
|
||||
this.reloadCurrentFileIconTheme();
|
||||
}
|
||||
} else {
|
||||
} else if (event.removed.some(t => t.settingsId === this.currentFileIconTheme.settingsId)) {
|
||||
// current theme is no longer available
|
||||
prevFileIconId = this.currentFileIconTheme.id;
|
||||
this.setFileIconTheme(DEFAULT_FILE_ICON_THEME_ID, 'auto');
|
||||
@@ -208,7 +196,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
|
||||
} else if (event.added.some(t => t.settingsId === this.currentProductIconTheme.settingsId)) {
|
||||
this.reloadCurrentProductIconTheme();
|
||||
}
|
||||
} else {
|
||||
} else if (event.removed.some(t => t.settingsId === this.currentProductIconTheme.settingsId)) {
|
||||
// current theme is no longer available
|
||||
prevProductIconId = this.currentProductIconTheme.id;
|
||||
this.setProductIconTheme(DEFAULT_PRODUCT_ICON_THEME_ID, 'auto');
|
||||
@@ -391,17 +379,19 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
|
||||
this.applyTheme(this.currentColorTheme, undefined, false);
|
||||
}
|
||||
|
||||
public restoreColorTheme() {
|
||||
const colorThemeSetting = this.settings.colorTheme;
|
||||
if (colorThemeSetting !== this.currentColorTheme.settingsId) {
|
||||
this.colorThemeRegistry.findThemeBySettingsId(colorThemeSetting, undefined).then(theme => {
|
||||
if (theme) {
|
||||
this.setColorTheme(theme.id, undefined);
|
||||
}
|
||||
});
|
||||
public async restoreColorTheme(): Promise<boolean> {
|
||||
const settingId = this.settings.colorTheme;
|
||||
const theme = await this.colorThemeRegistry.findThemeBySettingsId(settingId);
|
||||
if (theme) {
|
||||
if (settingId !== this.currentColorTheme.settingsId) {
|
||||
await this.setColorTheme(theme.id, undefined);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private updateDynamicCSSRules(themeData: IColorTheme) {
|
||||
const cssRules = new Set<string>();
|
||||
const ruleCollector = {
|
||||
|
||||
@@ -107,6 +107,7 @@ export function registerProductIconThemeExtensionPoint() {
|
||||
export interface ThemeChangeEvent<T> {
|
||||
themes: T[];
|
||||
added: T[];
|
||||
removed: T[];
|
||||
}
|
||||
|
||||
export interface IThemeData {
|
||||
@@ -135,10 +136,11 @@ export class ThemeRegistry<T extends IThemeData> {
|
||||
|
||||
private initialize() {
|
||||
this.themesExtPoint.setHandler((extensions, delta) => {
|
||||
const previousIds: { [key: string]: boolean } = {};
|
||||
const previousIds: { [key: string]: T } = {};
|
||||
|
||||
const added: T[] = [];
|
||||
for (const theme of this.extensionThemes) {
|
||||
previousIds[theme.id] = true;
|
||||
previousIds[theme.id] = theme;
|
||||
}
|
||||
this.extensionThemes.length = 0;
|
||||
for (let ext of extensions) {
|
||||
@@ -154,9 +156,12 @@ export class ThemeRegistry<T extends IThemeData> {
|
||||
for (const theme of this.extensionThemes) {
|
||||
if (!previousIds[theme.id]) {
|
||||
added.push(theme);
|
||||
} else {
|
||||
delete previousIds[theme.id];
|
||||
}
|
||||
}
|
||||
this.onDidChangeEmitter.fire({ themes: this.extensionThemes, added });
|
||||
const removed = Object.values(previousIds);
|
||||
this.onDidChangeEmitter.fire({ themes: this.extensionThemes, added, removed });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
|
||||
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
|
||||
import { StorageKeysSyncRegistryChannelClient } from 'vs/platform/userDataSync/common/userDataSyncIpc';
|
||||
|
||||
class StorageKeysSyncRegistryService extends StorageKeysSyncRegistryChannelClient implements IStorageKeysSyncRegistryService {
|
||||
|
||||
constructor(
|
||||
@IMainProcessService mainProcessService: IMainProcessService
|
||||
) {
|
||||
super(mainProcessService.getChannel('storageKeysSyncRegistryService'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
registerSingleton(IStorageKeysSyncRegistryService, StorageKeysSyncRegistryService);
|
||||
@@ -14,8 +14,7 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { VIEW_ID as SEARCH_VIEW_ID } from 'vs/workbench/services/search/common/search';
|
||||
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
|
||||
|
||||
class CounterSet<T> implements IReadableSet<T> {
|
||||
|
||||
@@ -192,6 +191,7 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
|
||||
private readonly viewDescriptorCollections: Map<ViewContainer, { viewDescriptorCollection: ViewDescriptorCollection, disposable: IDisposable; }>;
|
||||
private readonly activeViewContextKeys: Map<string, IContextKey<boolean>>;
|
||||
private readonly movableViewContextKeys: Map<string, IContextKey<boolean>>;
|
||||
private readonly defaultViewLocationContextKeys: Map<string, IContextKey<boolean>>;
|
||||
|
||||
private readonly viewsRegistry: IViewsRegistry;
|
||||
private readonly viewContainersRegistry: IViewContainersRegistry;
|
||||
@@ -219,13 +219,15 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
|
||||
@IContextKeyService private readonly contextKeyService: IContextKeyService,
|
||||
@IStorageService private readonly storageService: IStorageService,
|
||||
@IExtensionService private readonly extensionService: IExtensionService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||
@IStorageKeysSyncRegistryService storageKeysSyncRegistryService: IStorageKeysSyncRegistryService
|
||||
) {
|
||||
super();
|
||||
|
||||
storageKeysSyncRegistryService.registerStorageKey({ key: ViewDescriptorService.CACHED_VIEW_POSITIONS, version: 1 });
|
||||
this.viewDescriptorCollections = new Map<ViewContainer, { viewDescriptorCollection: ViewDescriptorCollection, disposable: IDisposable; }>();
|
||||
this.activeViewContextKeys = new Map<string, IContextKey<boolean>>();
|
||||
this.movableViewContextKeys = new Map<string, IContextKey<boolean>>();
|
||||
this.defaultViewLocationContextKeys = new Map<string, IContextKey<boolean>>();
|
||||
|
||||
this.viewContainersRegistry = Registry.as<IViewContainersRegistry>(ViewExtensions.ViewContainersRegistry);
|
||||
this.viewsRegistry = Registry.as<IViewsRegistry>(ViewExtensions.ViewsRegistry);
|
||||
@@ -254,33 +256,6 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
|
||||
this._register(this.storageService.onDidChangeStorage((e) => { this.onDidStorageChange(e); }));
|
||||
|
||||
this._register(this.extensionService.onDidRegisterExtensions(() => this.onDidRegisterExtensions()));
|
||||
|
||||
this._register(this.configurationService.onDidChangeConfiguration((changeEvent) => {
|
||||
if (changeEvent.affectedKeys.find(key => key === 'workbench.view.experimental.allowMovingToNewContainer')) {
|
||||
if (this.viewsCanMoveSettingValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
// update all moved views to their default locations
|
||||
for (const viewId of this.cachedViewInfo.keys()) {
|
||||
if (viewId === SEARCH_VIEW_ID) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const viewDescriptor = this.getViewDescriptor(viewId);
|
||||
const viewLocation = this.getViewContainer(viewId);
|
||||
const defaultLocation = this.getDefaultContainer(viewId);
|
||||
|
||||
if (viewDescriptor && viewLocation && defaultLocation && defaultLocation !== viewLocation) {
|
||||
this.moveViews([viewDescriptor], viewLocation, defaultLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private get viewsCanMoveSettingValue(): boolean {
|
||||
return !!this.configurationService.getValue<boolean>('workbench.view.experimental.allowMovingToNewContainer');
|
||||
}
|
||||
|
||||
private registerGroupedViews(groupedViews: Map<string, { cachedContainerInfo?: ICachedViewContainerInfo, views: IViewDescriptor[] }>): void {
|
||||
@@ -377,7 +352,7 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
|
||||
}
|
||||
|
||||
private shouldGenerateContainer(containerInfo: ICachedViewContainerInfo): boolean {
|
||||
return !!containerInfo.sourceViewId && containerInfo.location !== undefined && (this.viewsCanMoveSettingValue || containerInfo.sourceViewId === SEARCH_VIEW_ID);
|
||||
return !!containerInfo.sourceViewId && containerInfo.location !== undefined;
|
||||
}
|
||||
|
||||
private onDidDeregisterViews(views: IViewDescriptor[], viewContainer: ViewContainer): void {
|
||||
@@ -445,11 +420,7 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
|
||||
}
|
||||
|
||||
moveViewToLocation(view: IViewDescriptor, location: ViewContainerLocation): void {
|
||||
let container = this.getDefaultContainer(view.id)!;
|
||||
if (this.getViewContainerLocation(container) !== location) {
|
||||
container = this.registerViewContainerForSingleView(view, location);
|
||||
}
|
||||
|
||||
let container = this.registerViewContainerForSingleView(view, location);
|
||||
this.moveViewsToContainer([view], container);
|
||||
}
|
||||
|
||||
@@ -491,7 +462,7 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
|
||||
id,
|
||||
ctorDescriptor: new SyncDescriptor(ViewPaneContainer, [id, `${id}.state`, { mergeViewWithContainerWhenSingleView: true }]),
|
||||
name: sourceView.name,
|
||||
icon: sourceView.containerIcon,
|
||||
icon: location === ViewContainerLocation.Sidebar ? sourceView.containerIcon || 'codicon-window' : undefined,
|
||||
hideIfEmpty: true
|
||||
}, location);
|
||||
}
|
||||
@@ -675,12 +646,17 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
|
||||
const sourceViewId = this.generatedContainerSourceViewIds.get(container.id);
|
||||
views.forEach(view => {
|
||||
this.cachedViewInfo.set(view.id, { containerId: container.id, location, sourceViewId });
|
||||
this.getOrCreateDefaultViewLocationContextKey(view).set(this.getDefaultContainer(view.id) === container);
|
||||
});
|
||||
|
||||
this.getViewDescriptors(container).addViews(views);
|
||||
}
|
||||
|
||||
private removeViews(container: ViewContainer, views: IViewDescriptor[]): void {
|
||||
// Set view default location keys to false
|
||||
views.forEach(view => this.getOrCreateDefaultViewLocationContextKey(view).set(false));
|
||||
|
||||
// Remove the views
|
||||
this.getViewDescriptors(container).removeViews(views);
|
||||
}
|
||||
|
||||
@@ -703,6 +679,16 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
|
||||
}
|
||||
return contextKey;
|
||||
}
|
||||
|
||||
private getOrCreateDefaultViewLocationContextKey(viewDescriptor: IViewDescriptor): IContextKey<boolean> {
|
||||
const defaultViewLocationContextKeyId = `${viewDescriptor.id}.defaultViewLocation`;
|
||||
let contextKey = this.defaultViewLocationContextKeys.get(defaultViewLocationContextKeyId);
|
||||
if (!contextKey) {
|
||||
contextKey = new RawContextKey(defaultViewLocationContextKeyId, false).bindTo(this.contextKeyService);
|
||||
this.defaultViewLocationContextKeys.set(defaultViewLocationContextKeyId, contextKey);
|
||||
}
|
||||
return contextKey;
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(IViewDescriptorService, ViewDescriptorService);
|
||||
|
||||
Reference in New Issue
Block a user