mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)
* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 * fix pipelines * fix strict-null-checks * add missing files
This commit is contained in:
@@ -8,7 +8,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IContextKeyService, IContextKey, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { InputFocusedContext } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { IWindowsConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, TEXT_DIFF_EDITOR_ID, SplitEditorsVertically, InEditorZenModeContext, IsCenteredLayoutContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorIsSaveableContext, toResource, SideBySideEditor } from 'vs/workbench/common/editor';
|
||||
import { ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, TEXT_DIFF_EDITOR_ID, SplitEditorsVertically, InEditorZenModeContext, IsCenteredLayoutContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorIsSaveableContext, toResource, SideBySideEditor, EditorAreaVisibleContext } from 'vs/workbench/common/editor';
|
||||
import { trackFocus, addDisposableListener, EventType } from 'vs/base/browser/dom';
|
||||
import { preferredSideBySideGroupDirection, GroupDirection, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -73,6 +73,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
|
||||
private isFullscreenContext: IContextKey<boolean>;
|
||||
private isCenteredLayoutContext: IContextKey<boolean>;
|
||||
private sideBarVisibleContext: IContextKey<boolean>;
|
||||
private editorAreaVisibleContext: IContextKey<boolean>;
|
||||
private panelPositionContext: IContextKey<string>;
|
||||
|
||||
constructor(
|
||||
@@ -88,41 +89,6 @@ export class WorkbenchContextKeysHandler extends Disposable {
|
||||
) {
|
||||
super();
|
||||
|
||||
this.initContextKeys();
|
||||
this.registerListeners();
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
this.editorGroupService.whenRestored.then(() => this.updateEditorContextKeys());
|
||||
|
||||
this._register(this.editorService.onDidActiveEditorChange(() => this.updateEditorContextKeys()));
|
||||
this._register(this.editorService.onDidVisibleEditorsChange(() => this.updateEditorContextKeys()));
|
||||
|
||||
this._register(this.editorGroupService.onDidAddGroup(() => this.updateEditorContextKeys()));
|
||||
this._register(this.editorGroupService.onDidRemoveGroup(() => this.updateEditorContextKeys()));
|
||||
this._register(this.editorGroupService.onDidGroupIndexChange(() => this.updateEditorContextKeys()));
|
||||
|
||||
this._register(addDisposableListener(window, EventType.FOCUS_IN, () => this.updateInputContextKeys(), true));
|
||||
|
||||
this._register(this.contextService.onDidChangeWorkbenchState(() => this.updateWorkbenchStateContextKey()));
|
||||
this._register(this.contextService.onDidChangeWorkspaceFolders(() => this.updateWorkspaceFolderCountContextKey()));
|
||||
|
||||
this._register(this.configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration('workbench.editor.openSideBySideDirection')) {
|
||||
this.updateSplitEditorsVerticallyContext();
|
||||
}
|
||||
}));
|
||||
|
||||
this._register(this.layoutService.onZenModeChange(enabled => this.inZenModeContext.set(enabled)));
|
||||
this._register(this.layoutService.onFullscreenChange(fullscreen => this.isFullscreenContext.set(fullscreen)));
|
||||
this._register(this.layoutService.onCenteredLayoutChange(centered => this.isCenteredLayoutContext.set(centered)));
|
||||
this._register(this.layoutService.onPanelPositionChange(position => this.panelPositionContext.set(position)));
|
||||
|
||||
this._register(this.viewletService.onDidViewletClose(() => this.updateSideBarContextKeys()));
|
||||
this._register(this.viewletService.onDidViewletOpen(() => this.updateSideBarContextKeys()));
|
||||
}
|
||||
|
||||
private initContextKeys(): void {
|
||||
|
||||
// Platform
|
||||
IsMacContext.bindTo(this.contextKeyService);
|
||||
@@ -136,7 +102,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
|
||||
|
||||
// macOS Native Tabs
|
||||
const windowConfig = this.configurationService.getValue<IWindowsConfiguration>();
|
||||
HasMacNativeTabsContext.bindTo(this.contextKeyService).set(windowConfig && windowConfig.window && windowConfig.window.nativeTabs);
|
||||
HasMacNativeTabsContext.bindTo(this.contextKeyService).set(windowConfig?.window?.nativeTabs);
|
||||
|
||||
// Development
|
||||
IsDevelopmentContext.bindTo(this.contextKeyService).set(!this.environmentService.isBuilt || this.environmentService.isExtensionDevelopment);
|
||||
@@ -181,12 +147,49 @@ export class WorkbenchContextKeysHandler extends Disposable {
|
||||
// Centered Layout
|
||||
this.isCenteredLayoutContext = IsCenteredLayoutContext.bindTo(this.contextKeyService);
|
||||
|
||||
// Editor Area
|
||||
this.editorAreaVisibleContext = EditorAreaVisibleContext.bindTo(this.contextKeyService);
|
||||
|
||||
// Sidebar
|
||||
this.sideBarVisibleContext = SideBarVisibleContext.bindTo(this.contextKeyService);
|
||||
|
||||
// Panel Position
|
||||
this.panelPositionContext = PanelPositionContext.bindTo(this.contextKeyService);
|
||||
this.panelPositionContext.set(this.layoutService.getPanelPosition() === Position.RIGHT ? 'right' : 'bottom');
|
||||
|
||||
this.registerListeners();
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
this.editorGroupService.whenRestored.then(() => this.updateEditorContextKeys());
|
||||
|
||||
this._register(this.editorService.onDidActiveEditorChange(() => this.updateEditorContextKeys()));
|
||||
this._register(this.editorService.onDidVisibleEditorsChange(() => this.updateEditorContextKeys()));
|
||||
|
||||
this._register(this.editorGroupService.onDidAddGroup(() => this.updateEditorContextKeys()));
|
||||
this._register(this.editorGroupService.onDidRemoveGroup(() => this.updateEditorContextKeys()));
|
||||
this._register(this.editorGroupService.onDidGroupIndexChange(() => this.updateEditorContextKeys()));
|
||||
|
||||
this._register(addDisposableListener(window, EventType.FOCUS_IN, () => this.updateInputContextKeys(), true));
|
||||
|
||||
this._register(this.contextService.onDidChangeWorkbenchState(() => this.updateWorkbenchStateContextKey()));
|
||||
this._register(this.contextService.onDidChangeWorkspaceFolders(() => this.updateWorkspaceFolderCountContextKey()));
|
||||
|
||||
this._register(this.configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration('workbench.editor.openSideBySideDirection')) {
|
||||
this.updateSplitEditorsVerticallyContext();
|
||||
}
|
||||
}));
|
||||
|
||||
this._register(this.layoutService.onZenModeChange(enabled => this.inZenModeContext.set(enabled)));
|
||||
this._register(this.layoutService.onFullscreenChange(fullscreen => this.isFullscreenContext.set(fullscreen)));
|
||||
this._register(this.layoutService.onCenteredLayoutChange(centered => this.isCenteredLayoutContext.set(centered)));
|
||||
this._register(this.layoutService.onPanelPositionChange(position => this.panelPositionContext.set(position)));
|
||||
|
||||
this._register(this.viewletService.onDidViewletClose(() => this.updateSideBarContextKeys()));
|
||||
this._register(this.viewletService.onDidViewletOpen(() => this.updateSideBarContextKeys()));
|
||||
|
||||
this._register(this.layoutService.onPartVisibilityChange(() => this.editorAreaVisibleContext.set(this.layoutService.isVisible(Parts.EDITOR_PART))));
|
||||
}
|
||||
|
||||
private updateEditorContextKeys(): void {
|
||||
@@ -194,7 +197,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
|
||||
const activeControl = this.editorService.activeControl;
|
||||
const visibleEditors = this.editorService.visibleControls;
|
||||
|
||||
this.textCompareEditorActiveContext.set(!!activeControl && activeControl.getId() === TEXT_DIFF_EDITOR_ID);
|
||||
this.textCompareEditorActiveContext.set(activeControl?.getId() === TEXT_DIFF_EDITOR_ID);
|
||||
this.textCompareEditorVisibleContext.set(visibleEditors.some(control => control.getId() === TEXT_DIFF_EDITOR_ID));
|
||||
|
||||
if (visibleEditors.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user