Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add view movement tracing #195168

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/vs/workbench/browser/actions/layoutActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -924,16 +924,16 @@ class MoveFocusedViewAction extends Action2 {
const destination = quickPick.selectedItems[0];

if (destination.id === '_.panel.newcontainer') {
viewDescriptorService.moveViewToLocation(viewDescriptor!, ViewContainerLocation.Panel);
viewDescriptorService.moveViewToLocation(viewDescriptor!, ViewContainerLocation.Panel, this.desc.id);
viewsService.openView(focusedViewId, true);
} else if (destination.id === '_.sidebar.newcontainer') {
viewDescriptorService.moveViewToLocation(viewDescriptor!, ViewContainerLocation.Sidebar);
viewDescriptorService.moveViewToLocation(viewDescriptor!, ViewContainerLocation.Sidebar, this.desc.id);
viewsService.openView(focusedViewId, true);
} else if (destination.id === '_.auxiliarybar.newcontainer') {
viewDescriptorService.moveViewToLocation(viewDescriptor!, ViewContainerLocation.AuxiliaryBar);
viewDescriptorService.moveViewToLocation(viewDescriptor!, ViewContainerLocation.AuxiliaryBar, this.desc.id);
viewsService.openView(focusedViewId, true);
} else if (destination.id) {
viewDescriptorService.moveViewsToContainer([viewDescriptor], viewDescriptorService.getViewContainerById(destination.id)!);
viewDescriptorService.moveViewsToContainer([viewDescriptor], viewDescriptorService.getViewContainerById(destination.id)!, undefined, this.desc.id);
viewsService.openView(focusedViewId, true);
}

Expand Down Expand Up @@ -986,7 +986,7 @@ registerAction2(class extends Action2 {
return;
}

viewDescriptorService.moveViewsToContainer([viewDescriptor], defaultContainer);
viewDescriptorService.moveViewsToContainer([viewDescriptor], defaultContainer, undefined, this.desc.id);
viewsService.openView(viewDescriptor.id, true);
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/compositeBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ export class CompositeDragAndDrop implements ICompositeDragAndDrop {
}
// ... on a different composite bar
else {
this.viewDescriptorService.moveViewContainerToLocation(currentContainer, this.targetContainerLocation, this.getTargetIndex(targetCompositeId, before));
this.viewDescriptorService.moveViewContainerToLocation(currentContainer, this.targetContainerLocation, this.getTargetIndex(targetCompositeId, before), 'dnd');
}
}

if (dragData.type === 'view') {
const viewToMove = this.viewDescriptorService.getViewDescriptorById(dragData.id)!;
if (viewToMove && viewToMove.canMoveView) {
this.viewDescriptorService.moveViewToLocation(viewToMove, this.targetContainerLocation);
this.viewDescriptorService.moveViewToLocation(viewToMove, this.targetContainerLocation, 'dnd');

const newContainer = this.viewDescriptorService.getViewContainerByViewId(viewToMove.id)!;

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/paneCompositeBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ export class PaneCompositeBar extends Disposable {
const viewContainer = this.viewDescriptorService.getViewContainerById(compositeId)!;
const defaultLocation = this.viewDescriptorService.getDefaultViewContainerLocation(viewContainer)!;
if (defaultLocation !== this.viewDescriptorService.getViewContainerLocation(viewContainer)) {
actions.push(toAction({ id: 'resetLocationAction', label: localize('resetLocation', "Reset Location"), run: () => this.viewDescriptorService.moveViewContainerToLocation(viewContainer, defaultLocation) }));
actions.push(toAction({ id: 'resetLocationAction', label: localize('resetLocation', "Reset Location"), run: () => this.viewDescriptorService.moveViewContainerToLocation(viewContainer, defaultLocation, undefined, 'resetLocationAction') }));
} else {
const viewContainerModel = this.viewDescriptorService.getViewContainerModel(viewContainer);
if (viewContainerModel.allViewDescriptors.length === 1) {
const viewToReset = viewContainerModel.allViewDescriptors[0];
const defaultContainer = this.viewDescriptorService.getDefaultContainerById(viewToReset.id)!;
if (defaultContainer !== viewContainer) {
actions.push(toAction({ id: 'resetLocationAction', label: localize('resetLocation', "Reset Location"), run: () => this.viewDescriptorService.moveViewsToContainer([viewToReset], defaultContainer) }));
actions.push(toAction({ id: 'resetLocationAction', label: localize('resetLocation', "Reset Location"), run: () => this.viewDescriptorService.moveViewsToContainer([viewToReset], defaultContainer, undefined, 'resetLocationAction') }));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/parts/panel/panelActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ class MoveViewsBetweenPanelsAction extends Action2 {
if (srcContainers.length) {
const activeViewContainer = viewsService.getVisibleViewContainer(this.source);

srcContainers.forEach(viewContainer => viewDescriptorService.moveViewContainerToLocation(viewContainer, this.destination));
srcContainers.forEach(viewContainer => viewDescriptorService.moveViewContainerToLocation(viewContainer, this.destination, undefined, this.desc.id));
layoutService.setPartHidden(false, this.destination === ViewContainerLocation.Panel ? Parts.PANEL_PART : Parts.AUXILIARYBAR_PART);

if (activeViewContainer && destContainers.length === 0) {
Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/browser/parts/views/viewPaneContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,14 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
const oldViewContainer = this.viewDescriptorService.getViewContainerByViewId(dropData.id);
const viewDescriptor = this.viewDescriptorService.getViewDescriptorById(dropData.id);
if (oldViewContainer !== this.viewContainer && viewDescriptor && viewDescriptor.canMoveView) {
this.viewDescriptorService.moveViewsToContainer([viewDescriptor], this.viewContainer);
this.viewDescriptorService.moveViewsToContainer([viewDescriptor], this.viewContainer, undefined, 'dnd');
}
}

const paneCount = this.panes.length;

if (viewsToMove.length > 0) {
this.viewDescriptorService.moveViewsToContainer(viewsToMove, this.viewContainer);
this.viewDescriptorService.moveViewsToContainer(viewsToMove, this.viewContainer, undefined, 'dnd');
}

if (paneCount > 0) {
Expand Down Expand Up @@ -923,7 +923,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
}

if (viewsToMove) {
this.viewDescriptorService.moveViewsToContainer(viewsToMove, this.viewContainer);
this.viewDescriptorService.moveViewsToContainer(viewsToMove, this.viewContainer, undefined, 'dnd');
}

if (anchorView) {
Expand Down Expand Up @@ -1272,7 +1272,7 @@ registerAction2(class MoveViews extends Action2 {
for (const viewId of options.viewIds) {
const viewDescriptor = viewDescriptorService.getViewDescriptorById(viewId);
if (viewDescriptor?.canMoveView) {
viewDescriptorService.moveViewsToContainer([viewDescriptor], destination, ViewVisibilityState.Default);
viewDescriptorService.moveViewsToContainer([viewDescriptor], destination, ViewVisibilityState.Default, this.desc.id);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/views/viewsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,10 @@ export class ViewsService extends Disposable implements IViewsService {
// The default container is hidden so we should try to reset its location first
if (defaultContainer.hideIfEmpty && containerModel.visibleViewDescriptors.length === 0) {
const defaultLocation = viewDescriptorService.getDefaultViewContainerLocation(defaultContainer)!;
viewDescriptorService.moveViewContainerToLocation(defaultContainer, defaultLocation);
viewDescriptorService.moveViewContainerToLocation(defaultContainer, defaultLocation, undefined, this.desc.id);
}

viewDescriptorService.moveViewsToContainer([viewDescriptor], viewDescriptorService.getDefaultContainerById(viewDescriptor.id)!);
viewDescriptorService.moveViewsToContainer([viewDescriptor], viewDescriptorService.getDefaultContainerById(viewDescriptor.id)!, undefined, this.desc.id);
accessor.get(IViewsService).openView(viewDescriptor.id, true);
}
});
Expand Down
8 changes: 5 additions & 3 deletions src/vs/workbench/common/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { VSDataTransfer } from 'vs/base/common/dataTransfer';
import { ILocalizedString } from 'vs/platform/action/common/action';

export const VIEWS_LOG_ID = 'views';
export const VIEWS_LOG_NAME = localize('views log', "Views");
export const defaultViewIcon = registerIcon('default-view-icon', Codicon.window, localize('defaultViewIcon', 'Default view icon.'));

export namespace Extensions {
Expand Down Expand Up @@ -614,7 +616,7 @@ export interface IViewDescriptorService {
getViewContainerModel(viewContainer: ViewContainer): IViewContainerModel;

readonly onDidChangeContainerLocation: Event<{ viewContainer: ViewContainer; from: ViewContainerLocation; to: ViewContainerLocation }>;
moveViewContainerToLocation(viewContainer: ViewContainer, location: ViewContainerLocation, requestedIndex?: number): void;
moveViewContainerToLocation(viewContainer: ViewContainer, location: ViewContainerLocation, requestedIndex?: number, reason?: string): void;

getViewContainerBadgeEnablementState(id: string): boolean;
setViewContainerBadgeEnablementState(id: string, badgesEnabled: boolean): void;
Expand All @@ -626,10 +628,10 @@ export interface IViewDescriptorService {
getViewLocationById(id: string): ViewContainerLocation | null;

readonly onDidChangeContainer: Event<{ views: IViewDescriptor[]; from: ViewContainer; to: ViewContainer }>;
moveViewsToContainer(views: IViewDescriptor[], viewContainer: ViewContainer, visibilityState?: ViewVisibilityState): void;
moveViewsToContainer(views: IViewDescriptor[], viewContainer: ViewContainer, visibilityState?: ViewVisibilityState, reason?: string): void;

readonly onDidChangeLocation: Event<{ views: IViewDescriptor[]; from: ViewContainerLocation; to: ViewContainerLocation }>;
moveViewToLocation(view: IViewDescriptor, location: ViewContainerLocation): void;
moveViewToLocation(view: IViewDescriptor, location: ViewContainerLocation, reason?: string): void;

reset(): void;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class RegisterSearchViewContribution implements IWorkbenchContribution {
) {
const data = configurationService.inspect('search.location');
if (data.value === 'panel') {
viewDescriptorService.moveViewToLocation(viewDescriptor, ViewContainerLocation.Panel);
viewDescriptorService.moveViewToLocation(viewDescriptor, ViewContainerLocation.Panel, 'search.location');
}
Registry.as<IConfigurationMigrationRegistry>(Extensions.ConfigurationMigration)
.registerConfigurationMigrations([{ key: 'search.location', migrateFn: (value: any) => ({ value: undefined }) }]);
Expand Down
20 changes: 15 additions & 5 deletions src/vs/workbench/services/views/browser/viewDescriptorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ViewContainerLocation, IViewDescriptorService, ViewContainer, IViewsRegistry, IViewContainersRegistry, IViewDescriptor, Extensions as ViewExtensions, ViewVisibilityState, defaultViewIcon, ViewContainerLocationToString } from 'vs/workbench/common/views';
import { ViewContainerLocation, IViewDescriptorService, ViewContainer, IViewsRegistry, IViewContainersRegistry, IViewDescriptor, Extensions as ViewExtensions, ViewVisibilityState, defaultViewIcon, ViewContainerLocationToString, VIEWS_LOG_ID, VIEWS_LOG_NAME } from 'vs/workbench/common/views';
import { IContextKey, RawContextKey, IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
Expand All @@ -20,6 +20,7 @@ import { getViewsStateStorageId, ViewContainerModel } from 'vs/workbench/service
import { registerAction2, Action2, MenuId } from 'vs/platform/actions/common/actions';
import { localize } from 'vs/nls';
import { IStringDictionary } from 'vs/base/common/collections';
import { ILogger, ILoggerService } from 'vs/platform/log/common/log';

interface IViewsCustomizations {
viewContainerLocations: IStringDictionary<ViewContainerLocation>;
Expand Down Expand Up @@ -64,15 +65,20 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
readonly onDidChangeViewContainers = this._onDidChangeViewContainers.event;
get viewContainers(): ReadonlyArray<ViewContainer> { return this.viewContainersRegistry.all; }

private readonly logger: ILogger;

constructor(
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IStorageService private readonly storageService: IStorageService,
@IExtensionService private readonly extensionService: IExtensionService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
@ILoggerService loggerService: ILoggerService,
) {
super();

this.logger = loggerService.createLogger(VIEWS_LOG_ID, { name: VIEWS_LOG_NAME, hidden: true });

this.activeViewContextKeys = new Map<string, IContextKey<boolean>>();
this.movableViewContextKeys = new Map<string, IContextKey<boolean>>();
this.defaultViewLocationContextKeys = new Map<string, IContextKey<boolean>>();
Expand Down Expand Up @@ -302,7 +308,8 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
return this.viewContainersRegistry.getDefaultViewContainer(location);
}

moveViewContainerToLocation(viewContainer: ViewContainer, location: ViewContainerLocation, requestedIndex?: number): void {
moveViewContainerToLocation(viewContainer: ViewContainer, location: ViewContainerLocation, requestedIndex?: number, reason?: string): void {
this.logger.info(`moveViewContainerToLocation: viewContainer:${viewContainer.id} location:${location} reason:${reason}`);
this.moveViewContainerToLocationWithoutSaving(viewContainer, location, requestedIndex);
this.saveViewCustomizations();
}
Expand All @@ -316,16 +323,19 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
this.saveViewCustomizations();
}

moveViewToLocation(view: IViewDescriptor, location: ViewContainerLocation): void {
moveViewToLocation(view: IViewDescriptor, location: ViewContainerLocation, reason?: string): void {
this.logger.info(`moveViewToLocation: view:${view.id} location:${location} reason:${reason}`);
const container = this.registerGeneratedViewContainer(location);
this.moveViewsToContainer([view], container);
}

moveViewsToContainer(views: IViewDescriptor[], viewContainer: ViewContainer, visibilityState?: ViewVisibilityState): void {
moveViewsToContainer(views: IViewDescriptor[], viewContainer: ViewContainer, visibilityState?: ViewVisibilityState, reason?: string): void {
if (!views.length) {
return;
}

this.logger.info(`moveViewsToContainer: views:${views.map(view => view.id).join(',')} viewContainer:${viewContainer.id} reason:${reason}`);

const from = this.getViewContainerByViewId(views[0].id);
const to = viewContainer;

Expand Down Expand Up @@ -845,7 +855,7 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
});
}
run(): void {
that.moveViewContainerToLocation(viewContainer, that.getDefaultViewContainerLocation(viewContainer));
that.moveViewContainerToLocation(viewContainer, that.getDefaultViewContainerLocation(viewContainer), undefined, this.desc.id);
}
});
}
Expand Down
6 changes: 1 addition & 5 deletions src/vs/workbench/services/views/common/viewContainerModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ViewContainer, IViewsRegistry, IViewDescriptor, Extensions as ViewExtensions, IViewContainerModel, IAddedViewDescriptorRef, IViewDescriptorRef, IAddedViewDescriptorState, defaultViewIcon } from 'vs/workbench/common/views';
import { ViewContainer, IViewsRegistry, IViewDescriptor, Extensions as ViewExtensions, IViewContainerModel, IAddedViewDescriptorRef, IViewDescriptorRef, IAddedViewDescriptorState, defaultViewIcon, VIEWS_LOG_ID, VIEWS_LOG_NAME } from 'vs/workbench/common/views';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { Registry } from 'vs/platform/registry/common/platform';
Expand All @@ -16,16 +16,12 @@ import { isUndefined, isUndefinedOrNull } from 'vs/base/common/types';
import { isEqual } from 'vs/base/common/resources';
import { ThemeIcon } from 'vs/base/common/themables';
import { IStringDictionary } from 'vs/base/common/collections';
import { localize } from 'vs/nls';
import { ILogger, ILoggerService } from 'vs/platform/log/common/log';
import { Action2, registerAction2 } from 'vs/platform/actions/common/actions';
import { Categories } from 'vs/platform/action/common/actionCommonCategories';
import { IOutputService } from 'vs/workbench/services/output/common/output';
import { CounterSet } from 'vs/base/common/map';

const VIEWS_LOG_ID = 'views';
const VIEWS_LOG_NAME = localize('views log', "Views");

registerAction2(class extends Action2 {
constructor() {
super({
Expand Down