mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-31 09:10:30 -04:00
Merge from vscode 52dcb723a39ae75bee1bd56b3312d7fcdc87aeed (#6719)
This commit is contained in:
@@ -234,7 +234,7 @@ class DirtyDiffWidget extends PeekViewWidget {
|
||||
const changeTypeColor = getChangeTypeColor(this.themeService.getTheme(), changeType);
|
||||
this.style({ frameColor: changeTypeColor, arrowColor: changeTypeColor });
|
||||
|
||||
this._actionbarWidget.context = [this.model.modified!.uri, this.model.changes, index];
|
||||
this._actionbarWidget!.context = [this.model.modified!.uri, this.model.changes, index];
|
||||
this.show(position, height);
|
||||
this.editor.focus();
|
||||
}
|
||||
@@ -255,11 +255,11 @@ class DirtyDiffWidget extends PeekViewWidget {
|
||||
|
||||
this._disposables.add(previous);
|
||||
this._disposables.add(next);
|
||||
this._actionbarWidget.push([previous, next], { label: false, icon: true });
|
||||
this._actionbarWidget!.push([previous, next], { label: false, icon: true });
|
||||
|
||||
const actions: IAction[] = [];
|
||||
this._disposables.add(createAndFillInActionBarActions(this.menu, { shouldForwardArgs: true }, actions));
|
||||
this._actionbarWidget.push(actions, { label: false, icon: true });
|
||||
this._actionbarWidget!.push(actions, { label: false, icon: true });
|
||||
}
|
||||
|
||||
protected _getActionBarOptions(): IActionBarOptions {
|
||||
|
||||
@@ -13,10 +13,10 @@ import { IWorkbenchActionRegistry, Extensions as WorkbenchActionExtensions } fro
|
||||
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { StatusUpdater, StatusBarController } from './scmActivity';
|
||||
import { SCMStatusController } from './scmActivity';
|
||||
import { SCMViewlet } from 'vs/workbench/contrib/scm/browser/scmViewlet';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
@@ -48,10 +48,7 @@ Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new Vie
|
||||
));
|
||||
|
||||
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
|
||||
.registerWorkbenchContribution(StatusUpdater, LifecyclePhase.Restored);
|
||||
|
||||
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
|
||||
.registerWorkbenchContribution(StatusBarController, LifecyclePhase.Restored);
|
||||
.registerWorkbenchContribution(SCMStatusController, LifecyclePhase.Restored);
|
||||
|
||||
// Register Action to Open Viewlet
|
||||
Registry.as<IWorkbenchActionRegistry>(WorkbenchActionExtensions.WorkbenchActions).registerWorkbenchAction(
|
||||
@@ -70,10 +67,11 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
|
||||
order: 5,
|
||||
title: localize('scmConfigurationTitle', "SCM"),
|
||||
type: 'object',
|
||||
scope: ConfigurationScope.RESOURCE,
|
||||
properties: {
|
||||
'scm.alwaysShowProviders': {
|
||||
type: 'boolean',
|
||||
description: localize('alwaysShowProviders', "Controls whether to always show the Source Control Provider section."),
|
||||
description: localize('alwaysShowProviders', "Controls whether to show the Source Control Provider section even when there's only one Provider registered."),
|
||||
default: false
|
||||
},
|
||||
'scm.providers.visible': {
|
||||
@@ -97,6 +95,17 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
|
||||
type: 'boolean',
|
||||
description: localize('alwaysShowActions', "Controls whether inline actions are always visible in the Source Control view."),
|
||||
default: false
|
||||
},
|
||||
'scm.countBadge': {
|
||||
type: 'string',
|
||||
enum: ['all', 'focused', 'off'],
|
||||
enumDescriptions: [
|
||||
localize('scm.countBadge.all', "Show the sum of all Source Control Providers count badges."),
|
||||
localize('scm.countBadge.focused', "Show the count badge of the focused Source Control Provider."),
|
||||
localize('scm.countBadge.off', "Disable the Source Control count badge.")
|
||||
],
|
||||
description: localize('scm.countBadge', "Controls the Source Control count badge."),
|
||||
default: 'all'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,92 +14,45 @@ import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/c
|
||||
import { IStatusbarService, StatusbarAlignment as MainThreadStatusBarAlignment } from 'vs/platform/statusbar/common/statusbar';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { commonPrefixLength } from 'vs/base/common/strings';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
export class StatusUpdater implements IWorkbenchContribution {
|
||||
|
||||
private readonly badgeDisposable = new MutableDisposable<IDisposable>();
|
||||
private disposables: IDisposable[] = [];
|
||||
|
||||
constructor(
|
||||
@ISCMService private readonly scmService: ISCMService,
|
||||
@IActivityService private readonly activityService: IActivityService,
|
||||
@ILogService private readonly logService: ILogService
|
||||
) {
|
||||
for (const repository of this.scmService.repositories) {
|
||||
this.onDidAddRepository(repository);
|
||||
}
|
||||
|
||||
this.scmService.onDidAddRepository(this.onDidAddRepository, this, this.disposables);
|
||||
this.render();
|
||||
}
|
||||
|
||||
private onDidAddRepository(repository: ISCMRepository): void {
|
||||
const provider = repository.provider;
|
||||
const onDidChange = Event.any(provider.onDidChange, provider.onDidChangeResources);
|
||||
const changeDisposable = onDidChange(() => this.render());
|
||||
|
||||
const onDidRemove = Event.filter(this.scmService.onDidRemoveRepository, e => e === repository);
|
||||
const removeDisposable = onDidRemove(() => {
|
||||
disposable.dispose();
|
||||
this.disposables = this.disposables.filter(d => d !== removeDisposable);
|
||||
this.render();
|
||||
});
|
||||
|
||||
const disposable = combinedDisposable(changeDisposable, removeDisposable);
|
||||
this.disposables.push(disposable);
|
||||
}
|
||||
|
||||
private render(): void {
|
||||
this.badgeDisposable.clear();
|
||||
|
||||
const count = this.scmService.repositories.reduce((r, repository) => {
|
||||
if (typeof repository.provider.count === 'number') {
|
||||
return r + repository.provider.count;
|
||||
} else {
|
||||
return r + repository.provider.groups.elements.reduce<number>((r, g) => r + g.elements.length, 0);
|
||||
}
|
||||
}, 0);
|
||||
|
||||
// TODO@joao: remove
|
||||
this.logService.trace('SCM#StatusUpdater.render', count);
|
||||
|
||||
if (count > 0) {
|
||||
const badge = new NumberBadge(count, num => localize('scmPendingChangesBadge', '{0} pending changes', num));
|
||||
this.badgeDisposable.value = this.activityService.showActivity(VIEWLET_ID, badge, 'scm-viewlet-label');
|
||||
} else {
|
||||
this.badgeDisposable.clear();
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.badgeDisposable.dispose();
|
||||
this.disposables = dispose(this.disposables);
|
||||
function getCount(repository: ISCMRepository): number {
|
||||
if (typeof repository.provider.count === 'number') {
|
||||
return repository.provider.count;
|
||||
} else {
|
||||
return repository.provider.groups.elements.reduce<number>((r, g) => r + g.elements.length, 0);
|
||||
}
|
||||
}
|
||||
|
||||
export class StatusBarController implements IWorkbenchContribution {
|
||||
export class SCMStatusController implements IWorkbenchContribution {
|
||||
|
||||
private statusBarDisposable: IDisposable = Disposable.None;
|
||||
private focusDisposable: IDisposable = Disposable.None;
|
||||
private focusedRepository: ISCMRepository | undefined = undefined;
|
||||
private focusedProviderContextKey: IContextKey<string | undefined>;
|
||||
private readonly badgeDisposable = new MutableDisposable<IDisposable>();
|
||||
private disposables: IDisposable[] = [];
|
||||
|
||||
constructor(
|
||||
@ISCMService private readonly scmService: ISCMService,
|
||||
@IStatusbarService private readonly statusbarService: IStatusbarService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IEditorService private readonly editorService: IEditorService
|
||||
@IContextKeyService readonly contextKeyService: IContextKeyService,
|
||||
@IActivityService private readonly activityService: IActivityService,
|
||||
@IEditorService private readonly editorService: IEditorService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||
) {
|
||||
this.focusedProviderContextKey = contextKeyService.createKey<string | undefined>('scmProvider', undefined);
|
||||
this.scmService.onDidAddRepository(this.onDidAddRepository, this, this.disposables);
|
||||
|
||||
const onDidChangeSCMCountBadge = Event.filter(configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.countBadge'));
|
||||
onDidChangeSCMCountBadge(this.renderActivityCount, this, this.disposables);
|
||||
|
||||
for (const repository of this.scmService.repositories) {
|
||||
this.onDidAddRepository(repository);
|
||||
}
|
||||
|
||||
editorService.onDidActiveEditorChange(this.onDidActiveEditorChange, this, this.disposables);
|
||||
this.renderActivityCount();
|
||||
}
|
||||
|
||||
private onDidActiveEditorChange(): void {
|
||||
@@ -138,7 +91,11 @@ export class StatusBarController implements IWorkbenchContribution {
|
||||
}
|
||||
|
||||
private onDidAddRepository(repository: ISCMRepository): void {
|
||||
const changeDisposable = repository.onDidFocus(() => this.onDidFocusRepository(repository));
|
||||
const focusDisposable = repository.onDidFocus(() => this.onDidFocusRepository(repository));
|
||||
|
||||
const onDidChange = Event.any(repository.provider.onDidChange, repository.provider.onDidChangeResources);
|
||||
const changeDisposable = onDidChange(() => this.renderActivityCount());
|
||||
|
||||
const onDidRemove = Event.filter(this.scmService.onDidRemoveRepository, e => e === repository);
|
||||
const removeDisposable = onDidRemove(() => {
|
||||
disposable.dispose();
|
||||
@@ -149,9 +106,11 @@ export class StatusBarController implements IWorkbenchContribution {
|
||||
} else if (this.focusedRepository === repository) {
|
||||
this.scmService.repositories[0].focus();
|
||||
}
|
||||
|
||||
this.renderActivityCount();
|
||||
});
|
||||
|
||||
const disposable = combinedDisposable(changeDisposable, removeDisposable);
|
||||
const disposable = combinedDisposable(focusDisposable, changeDisposable, removeDisposable);
|
||||
this.disposables.push(disposable);
|
||||
|
||||
if (!this.focusedRepository) {
|
||||
@@ -169,13 +128,14 @@ export class StatusBarController implements IWorkbenchContribution {
|
||||
this.focusDisposable.dispose();
|
||||
|
||||
if (repository && repository.provider.onDidChangeStatusBarCommands) {
|
||||
this.focusDisposable = repository.provider.onDidChangeStatusBarCommands(() => this.render(repository));
|
||||
this.focusDisposable = repository.provider.onDidChangeStatusBarCommands(() => this.renderStatusBar(repository));
|
||||
}
|
||||
|
||||
this.render(repository);
|
||||
this.renderStatusBar(repository);
|
||||
this.renderActivityCount();
|
||||
}
|
||||
|
||||
private render(repository: ISCMRepository | undefined): void {
|
||||
private renderStatusBar(repository: ISCMRepository | undefined): void {
|
||||
this.statusBarDisposable.dispose();
|
||||
|
||||
if (!repository) {
|
||||
@@ -200,9 +160,31 @@ export class StatusBarController implements IWorkbenchContribution {
|
||||
this.statusBarDisposable = disposables;
|
||||
}
|
||||
|
||||
private renderActivityCount(): void {
|
||||
this.badgeDisposable.clear();
|
||||
|
||||
const countBadgeType = this.configurationService.getValue<'all' | 'focused' | 'off'>('scm.countBadge');
|
||||
|
||||
let count = 0;
|
||||
|
||||
if (countBadgeType === 'all') {
|
||||
count = this.scmService.repositories.reduce((r, repository) => r + getCount(repository), 0);
|
||||
} else if (countBadgeType === 'focused' && this.focusedRepository) {
|
||||
count = getCount(this.focusedRepository);
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
const badge = new NumberBadge(count, num => localize('scmPendingChangesBadge', '{0} pending changes', num));
|
||||
this.badgeDisposable.value = this.activityService.showActivity(VIEWLET_ID, badge, 'scm-viewlet-label');
|
||||
} else {
|
||||
this.badgeDisposable.clear();
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.focusDisposable.dispose();
|
||||
this.statusBarDisposable.dispose();
|
||||
this.badgeDisposable.dispose();
|
||||
this.disposables = dispose(this.disposables);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IViewsRegistry, IViewDescriptor, Extensions } from 'vs/workbench/common/views';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { nextTick } from 'vs/base/common/process';
|
||||
|
||||
export interface ISpliceEvent<T> {
|
||||
index: number;
|
||||
@@ -324,7 +325,7 @@ export class MainPanel extends ViewletPanel {
|
||||
}
|
||||
|
||||
private onListSelectionChange(e: IListEvent<ISCMRepository>): void {
|
||||
if (e.elements.length > 0) {
|
||||
if (e.browserEvent && e.elements.length > 0) {
|
||||
const scrollTop = this.list.scrollTop;
|
||||
this.viewModel.setVisibleRepositories(e.elements);
|
||||
this.list.scrollTop = scrollTop;
|
||||
@@ -332,7 +333,7 @@ export class MainPanel extends ViewletPanel {
|
||||
}
|
||||
|
||||
private onListFocusChange(e: IListEvent<ISCMRepository>): void {
|
||||
if (e.elements.length > 0) {
|
||||
if (e.browserEvent && e.elements.length > 0) {
|
||||
e.elements[0].focus();
|
||||
}
|
||||
}
|
||||
@@ -797,7 +798,7 @@ export class RepositoryPanel extends ViewletPanel {
|
||||
|
||||
const triggerValidation = () => validationDelayer.trigger(validate);
|
||||
|
||||
this.inputBox = new InputBox(this.inputBoxContainer, this.contextViewService, { flexibleHeight: true });
|
||||
this.inputBox = new InputBox(this.inputBoxContainer, this.contextViewService, { flexibleHeight: true, flexibleMaxHeight: 134 });
|
||||
this.inputBox.setEnabled(this.isBodyVisible());
|
||||
this._register(attachInputBoxStyler(this.inputBox, this.themeService));
|
||||
this._register(this.inputBox);
|
||||
@@ -896,11 +897,8 @@ export class RepositoryPanel extends ViewletPanel {
|
||||
const listHeight = height - (editorHeight + 12 /* margin */);
|
||||
this.listContainer.style.height = `${listHeight}px`;
|
||||
this.list.layout(listHeight, width);
|
||||
|
||||
toggleClass(this.inputBoxContainer, 'scroll', editorHeight >= 134);
|
||||
} else {
|
||||
addClass(this.inputBoxContainer, 'hidden');
|
||||
removeClass(this.inputBoxContainer, 'scroll');
|
||||
|
||||
this.listContainer.style.height = `${height}px`;
|
||||
this.list.layout(height, width);
|
||||
@@ -1105,6 +1103,9 @@ export class SCMViewlet extends ViewContainerViewlet implements IViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
private readonly _onDidChangeRepositories = new Emitter<void>();
|
||||
private readonly onDidFinishStartup = Event.once(Event.debounce(this._onDidChangeRepositories.event, () => null, 1000));
|
||||
|
||||
constructor(
|
||||
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@@ -1133,6 +1134,9 @@ export class SCMViewlet extends ViewContainerViewlet implements IViewModel {
|
||||
this.onDidChangeRepositories();
|
||||
}
|
||||
}));
|
||||
|
||||
this._register(this.onDidFinishStartup(this.onAfterStartup, this));
|
||||
this._register(this.viewsModel.onDidRemove(this.onDidHideView, this));
|
||||
}
|
||||
|
||||
create(parent: HTMLElement): void {
|
||||
@@ -1193,20 +1197,28 @@ export class SCMViewlet extends ViewContainerViewlet implements IViewModel {
|
||||
|
||||
if (alwaysShowProviders && repositoryCount > 0) {
|
||||
this.viewsModel.setVisible(MainPanel.ID, true);
|
||||
} else if (!alwaysShowProviders && repositoryCount === 1) {
|
||||
this.viewsModel.setVisible(MainPanel.ID, false);
|
||||
} else if (this.repositoryCount < 2 && repositoryCount >= 2) {
|
||||
this.viewsModel.setVisible(MainPanel.ID, true);
|
||||
} else if (this.repositoryCount >= 2 && repositoryCount === 1) {
|
||||
this.viewsModel.setVisible(MainPanel.ID, false);
|
||||
}
|
||||
|
||||
if (repositoryCount === 1) {
|
||||
this.viewsModel.setVisible(this.viewDescriptors[0].id, true);
|
||||
}
|
||||
|
||||
toggleClass(this.el, 'empty', repositoryCount === 0);
|
||||
this.repositoryCount = repositoryCount;
|
||||
|
||||
this._onDidChangeRepositories.fire();
|
||||
}
|
||||
|
||||
private onAfterStartup(): void {
|
||||
if (this.repositoryCount > 0 && this.viewDescriptors.every(d => !this.viewsModel.isVisible(d.id))) {
|
||||
this.viewsModel.setVisible(this.viewDescriptors[0].id, true);
|
||||
}
|
||||
}
|
||||
|
||||
private onDidHideView(): void {
|
||||
nextTick(() => {
|
||||
if (this.repositoryCount > 0 && this.viewDescriptors.every(d => !this.viewsModel.isVisible(d.id))) {
|
||||
const alwaysShowProviders = this.configurationService.getValue<boolean>('scm.alwaysShowProviders') || false;
|
||||
this.viewsModel.setVisible(MainPanel.ID, alwaysShowProviders || this.repositoryCount > 1);
|
||||
this.viewsModel.setVisible(this.viewDescriptors[0].id, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
focus(): void {
|
||||
|
||||
Reference in New Issue
Block a user