mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode cfbd1999769f4f08dce29629fb92fdc0fac53829
This commit is contained in:
@@ -523,7 +523,6 @@ function focusElement(accessor: ServicesAccessor, retainCurrentFocus: boolean):
|
||||
}
|
||||
}
|
||||
tree.setSelection(focus, fakeKeyboardEvent);
|
||||
tree.open(fakeKeyboardEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -655,18 +654,17 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
const focused = accessor.get(IListService).lastFocusedList;
|
||||
|
||||
// Tree only
|
||||
if (focused && !(focused instanceof List || focused instanceof PagedList)) {
|
||||
if (focused instanceof ObjectTree || focused instanceof DataTree || focused instanceof AsyncDataTree) {
|
||||
const tree = focused;
|
||||
const focus = tree.getFocus();
|
||||
|
||||
if (focus.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (focused instanceof ObjectTree || focused instanceof DataTree || focused instanceof AsyncDataTree) {
|
||||
const tree = focused;
|
||||
const focus = tree.getFocus();
|
||||
|
||||
if (focus.length > 0 && tree.isCollapsible(focus[0])) {
|
||||
tree.toggleCollapsed(focus[0]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
focusElement(accessor, true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import { AuthenticationSession } from 'vs/editor/common/modes';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { ActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
export class ViewContainerActivityAction extends ActivityAction {
|
||||
|
||||
@@ -41,6 +42,7 @@ export class ViewContainerActivityAction extends ActivityAction {
|
||||
private readonly viewletService: IViewletService;
|
||||
private readonly layoutService: IWorkbenchLayoutService;
|
||||
private readonly telemetryService: ITelemetryService;
|
||||
private readonly configurationService: IConfigurationService;
|
||||
|
||||
private lastRun: number;
|
||||
|
||||
@@ -48,7 +50,8 @@ export class ViewContainerActivityAction extends ActivityAction {
|
||||
activity: IActivity,
|
||||
@IViewletService viewletService: IViewletService,
|
||||
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
|
||||
@ITelemetryService telemetryService: ITelemetryService
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IConfigurationService configurationService: IConfigurationService
|
||||
) {
|
||||
super(activity);
|
||||
|
||||
@@ -56,6 +59,7 @@ export class ViewContainerActivityAction extends ActivityAction {
|
||||
this.viewletService = viewletService;
|
||||
this.layoutService = layoutService;
|
||||
this.telemetryService = telemetryService;
|
||||
this.configurationService = configurationService;
|
||||
}
|
||||
|
||||
updateActivity(activity: IActivity): void {
|
||||
@@ -76,11 +80,22 @@ export class ViewContainerActivityAction extends ActivityAction {
|
||||
|
||||
const sideBarVisible = this.layoutService.isVisible(Parts.SIDEBAR_PART);
|
||||
const activeViewlet = this.viewletService.getActiveViewlet();
|
||||
const focusBehavior = this.configurationService.getValue<string>('workbench.activityBar.iconClickBehavior');
|
||||
|
||||
// Hide sidebar if selected viewlet already visible
|
||||
if (sideBarVisible && activeViewlet?.getId() === this.activity.id) {
|
||||
this.logAction('hide');
|
||||
this.layoutService.setSideBarHidden(true);
|
||||
switch (focusBehavior) {
|
||||
case 'focus':
|
||||
this.logAction('refocus');
|
||||
this.viewletService.openViewlet(this.activity.id, true);
|
||||
break;
|
||||
case 'toggle':
|
||||
default:
|
||||
// Hide sidebar if selected viewlet already visible
|
||||
this.logAction('hide');
|
||||
this.layoutService.setSideBarHidden(true);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,8 @@ export class ActivitybarPart extends Part implements IActivityBarService {
|
||||
|
||||
private accountsActivityAction: ActivityAction | undefined;
|
||||
|
||||
private accountsActivity: ICompositeActivity[] = [];
|
||||
|
||||
private readonly compositeActions = new Map<string, { activityAction: ViewContainerActivityAction, pinnedAction: ToggleCompositePinnedAction }>();
|
||||
private readonly viewContainerDisposables = new Map<string, IDisposable>();
|
||||
|
||||
@@ -321,65 +323,64 @@ export class ActivitybarPart extends Part implements IActivityBarService {
|
||||
}
|
||||
|
||||
if (viewContainerOrActionId === GLOBAL_ACTIVITY_ID) {
|
||||
return this.showGlobalActivity(badge, clazz, priority);
|
||||
return this.showGlobalActivity(this.globalActivity, this.globalActivityAction, badge, clazz, priority);
|
||||
}
|
||||
|
||||
if (viewContainerOrActionId === ACCOUNTS_ACTIIVTY_ID) {
|
||||
if (this.accountsActivityAction) {
|
||||
this.accountsActivityAction.setBadge(badge, clazz);
|
||||
|
||||
return toDisposable(() => this.accountsActivityAction?.setBadge(undefined));
|
||||
}
|
||||
return this.showGlobalActivity(this.accountsActivity, this.accountsActivityAction, badge, clazz, priority);
|
||||
}
|
||||
|
||||
return Disposable.None;
|
||||
}
|
||||
|
||||
private showGlobalActivity(badge: IBadge, clazz?: string, priority?: number): IDisposable {
|
||||
private showGlobalActivity(activityCache: ICompositeActivity[], activityAction: ActivityAction | undefined, badge: IBadge, clazz?: string, priority?: number): IDisposable {
|
||||
if (typeof priority !== 'number') {
|
||||
priority = 0;
|
||||
}
|
||||
const activity: ICompositeActivity = { badge, clazz, priority };
|
||||
|
||||
for (let i = 0; i <= this.globalActivity.length; i++) {
|
||||
if (i === this.globalActivity.length) {
|
||||
this.globalActivity.push(activity);
|
||||
for (let i = 0; i <= activityCache.length; i++) {
|
||||
if (i === activityCache.length) {
|
||||
activityCache.push(activity);
|
||||
break;
|
||||
} else if (this.globalActivity[i].priority <= priority) {
|
||||
this.globalActivity.splice(i, 0, activity);
|
||||
} else if (activityCache[i].priority <= priority) {
|
||||
activityCache.splice(i, 0, activity);
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.updateGlobalActivity();
|
||||
this.updateGlobalActivity(activityCache, activityAction);
|
||||
|
||||
return toDisposable(() => this.removeGlobalActivity(activity));
|
||||
return toDisposable(() => this.removeGlobalActivity(activityCache, activityAction, activity));
|
||||
}
|
||||
|
||||
private removeGlobalActivity(activity: ICompositeActivity): void {
|
||||
const index = this.globalActivity.indexOf(activity);
|
||||
private removeGlobalActivity(activityCache: ICompositeActivity[], activityAction: ActivityAction | undefined, activity: ICompositeActivity): void {
|
||||
const index = activityCache.indexOf(activity);
|
||||
if (index !== -1) {
|
||||
this.globalActivity.splice(index, 1);
|
||||
this.updateGlobalActivity();
|
||||
activityCache.splice(index, 1);
|
||||
this.updateGlobalActivity(activityCache, activityAction);
|
||||
}
|
||||
}
|
||||
|
||||
private updateGlobalActivity(): void {
|
||||
const globalActivityAction = assertIsDefined(this.globalActivityAction);
|
||||
if (this.globalActivity.length) {
|
||||
const [{ badge, clazz, priority }] = this.globalActivity;
|
||||
if (badge instanceof NumberBadge && this.globalActivity.length > 1) {
|
||||
const cumulativeNumberBadge = this.getCumulativeNumberBadge(priority);
|
||||
globalActivityAction.setBadge(cumulativeNumberBadge);
|
||||
private updateGlobalActivity(activityCache: ICompositeActivity[], activityAction: ActivityAction | undefined): void {
|
||||
if (!activityAction) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (activityCache.length) {
|
||||
const [{ badge, clazz, priority }] = activityCache;
|
||||
if (badge instanceof NumberBadge && activityCache.length > 1) {
|
||||
const cumulativeNumberBadge = this.getCumulativeNumberBadge(activityCache, priority);
|
||||
activityAction.setBadge(cumulativeNumberBadge);
|
||||
} else {
|
||||
globalActivityAction.setBadge(badge, clazz);
|
||||
activityAction.setBadge(badge, clazz);
|
||||
}
|
||||
} else {
|
||||
globalActivityAction.setBadge(undefined);
|
||||
activityAction.setBadge(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
private getCumulativeNumberBadge(priority: number): NumberBadge {
|
||||
const numberActivities = this.globalActivity.filter(activity => activity.badge instanceof NumberBadge && activity.priority === priority);
|
||||
private getCumulativeNumberBadge(activityCache: ICompositeActivity[], priority: number): NumberBadge {
|
||||
const numberActivities = activityCache.filter(activity => activity.badge instanceof NumberBadge && activity.priority === priority);
|
||||
let number = numberActivities.reduce((result, activity) => { return result + (<NumberBadge>activity.badge).number; }, 0);
|
||||
let descriptorFn = (): string => {
|
||||
return numberActivities.reduce((result, activity, index) => {
|
||||
@@ -628,6 +629,8 @@ export class ActivitybarPart extends Part implements IActivityBarService {
|
||||
this.globalActivityActionBar.push(this.accountsActivityAction, { index: ActivitybarPart.ACCOUNTS_ACTION_INDEX });
|
||||
}
|
||||
}
|
||||
|
||||
this.updateGlobalActivity(this.accountsActivity, this.accountsActivityAction);
|
||||
}
|
||||
|
||||
private getCompositeActions(compositeId: string): { activityAction: ViewContainerActivityAction, pinnedAction: ToggleCompositePinnedAction } {
|
||||
|
||||
@@ -231,6 +231,16 @@ import { workbenchConfigurationNodeBase } from 'vs/workbench/common/configuratio
|
||||
'default': true,
|
||||
'description': nls.localize('activityBarVisibility', "Controls the visibility of the activity bar in the workbench.")
|
||||
},
|
||||
'workbench.activityBar.iconClickBehavior': {
|
||||
'type': 'string',
|
||||
'enum': ['toggle', 'focus'],
|
||||
'default': 'toggle',
|
||||
'description': nls.localize('activityBarIconClickBehavior', "Controls the behavior of clicking an activity bar icon in the workbench."),
|
||||
'enumDescriptions': [
|
||||
nls.localize('workbench.activityBar.iconClickBehavior.toggle', "Hide the side bar if the clicked item is already visible."),
|
||||
nls.localize('workbench.activityBar.iconClickBehavior.focus', "Focus side bar if the clicked item is already visible.")
|
||||
]
|
||||
},
|
||||
'workbench.view.alwaysShowHeaderActions': {
|
||||
'type': 'boolean',
|
||||
'default': true, // {{SQL CARBON EDIT}} - change the default value from false to true.
|
||||
|
||||
Reference in New Issue
Block a user