Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)

* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973

* disable strict null check
This commit is contained in:
Anthony Dresser
2019-07-15 22:35:46 -07:00
committed by GitHub
parent f720ec642f
commit 0b7e7ddbf9
2406 changed files with 59140 additions and 35464 deletions

View File

@@ -8,7 +8,7 @@ import { localize } from 'vs/nls';
import { Event, Emitter } from 'vs/base/common/event';
import { domEvent } from 'vs/base/browser/event';
import { basename } from 'vs/base/common/resources';
import { IDisposable, dispose, combinedDisposable, Disposable } from 'vs/base/common/lifecycle';
import { IDisposable, dispose, Disposable, DisposableStore, combinedDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { ViewletPanel, IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet';
import { append, $, addClass, toggleClass, trackFocus, removeClass, addClasses } from 'vs/base/browser/dom';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
@@ -25,7 +25,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { MenuItemAction, IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions';
import { IAction, Action, IActionViewItem, ActionRunner } from 'vs/base/common/actions';
import { fillInContextMenuActions, ContextAwareMenuEntryActionViewItem, fillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
import { createAndFillInContextMenuActions, ContextAwareMenuEntryActionViewItem, createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
import { SCMMenus } from './scmMenus';
import { ActionBar, IActionViewItemProvider, ActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IThemeService, LIGHT } from 'vs/platform/theme/common/themeService';
@@ -108,26 +108,32 @@ class StatusBarActionViewItem extends ActionViewItem {
}
function connectPrimaryMenuToInlineActionBar(menu: IMenu, actionBar: ActionBar): IDisposable {
let cachedDisposable: IDisposable = Disposable.None;
let cachedPrimary: IAction[] = [];
const updateActions = () => {
const primary: IAction[] = [];
const secondary: IAction[] = [];
const result = { primary, secondary };
fillInActionBarActions(menu, { shouldForwardArgs: true }, result, g => /^inline/.test(g));
const disposable = createAndFillInActionBarActions(menu, { shouldForwardArgs: true }, { primary, secondary }, g => /^inline/.test(g));
if (equals(cachedPrimary, primary, (a, b) => a.id === b.id)) {
disposable.dispose();
return;
}
cachedDisposable = disposable;
cachedPrimary = primary;
actionBar.clear();
actionBar.push(primary, { icon: true, label: false });
};
updateActions();
return menu.onDidChange(updateActions);
return combinedDisposable(menu.onDidChange(updateActions), toDisposable(() => {
cachedDisposable.dispose();
}));
}
interface RepositoryTemplateData {
@@ -162,14 +168,14 @@ class ProviderRenderer implements IListRenderer<ISCMRepository, RepositoryTempla
const badgeStyler = attachBadgeStyler(count, this.themeService);
const actionBar = new ActionBar(provider, { actionViewItemProvider: a => new StatusBarActionViewItem(a as StatusBarAction) });
const disposable = Disposable.None;
const templateDisposable = combinedDisposable([actionBar, badgeStyler]);
const templateDisposable = combinedDisposable(actionBar, badgeStyler);
return { title, type, countContainer, count, actionBar, disposable, templateDisposable };
}
renderElement(repository: ISCMRepository, index: number, templateData: RepositoryTemplateData): void {
templateData.disposable.dispose();
const disposables: IDisposable[] = [];
const disposables = new DisposableStore();
if (repository.provider.rootUri) {
templateData.title.textContent = basename(repository.provider.rootUri);
@@ -181,7 +187,7 @@ class ProviderRenderer implements IListRenderer<ISCMRepository, RepositoryTempla
const actions: IAction[] = [];
const disposeActions = () => dispose(actions);
disposables.push({ dispose: disposeActions });
disposables.add({ dispose: disposeActions });
const update = () => {
disposeActions();
@@ -198,10 +204,10 @@ class ProviderRenderer implements IListRenderer<ISCMRepository, RepositoryTempla
this._onDidRenderElement.fire(repository);
};
repository.provider.onDidChange(update, null, disposables);
disposables.add(repository.provider.onDidChange(update, null));
update();
templateData.disposable = combinedDisposable(disposables);
templateData.disposable = disposables;
}
disposeTemplate(templateData: RepositoryTemplateData): void {
@@ -241,23 +247,23 @@ export class MainPanel extends ViewletPanel {
horizontalScrolling: false
}) as WorkbenchList<ISCMRepository>;
renderer.onDidRenderElement(e => this.list.updateWidth(this.viewModel.repositories.indexOf(e)), null, this.disposables);
this.list.onSelectionChange(this.onListSelectionChange, this, this.disposables);
this.list.onFocusChange(this.onListFocusChange, this, this.disposables);
this.list.onContextMenu(this.onListContextMenu, this, this.disposables);
this._register(renderer.onDidRenderElement(e => this.list.updateWidth(this.viewModel.repositories.indexOf(e)), null));
this._register(this.list.onSelectionChange(this.onListSelectionChange, this));
this._register(this.list.onFocusChange(this.onListFocusChange, this));
this._register(this.list.onContextMenu(this.onListContextMenu, this));
this.viewModel.onDidChangeVisibleRepositories(this.updateListSelection, this, this.disposables);
this._register(this.viewModel.onDidChangeVisibleRepositories(this.updateListSelection, this));
this.viewModel.onDidSplice(({ index, deleteCount, elements }) => this.splice(index, deleteCount, elements), null, this.disposables);
this._register(this.viewModel.onDidSplice(({ index, deleteCount, elements }) => this.splice(index, deleteCount, elements), null));
this.splice(0, 0, this.viewModel.repositories);
this.disposables.push(this.list);
this._register(this.list);
this.configurationService.onDidChangeConfiguration(e => {
this._register(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('scm.providers.visible')) {
this.updateBodySize();
}
}, this.disposables);
}));
this.updateListSelection();
}
@@ -299,7 +305,7 @@ export class MainPanel extends ViewletPanel {
const secondary: IAction[] = [];
const result = { primary, secondary };
fillInContextMenuActions(menu, { shouldForwardArgs: true }, result, this.contextMenuService, g => g === 'inline');
const disposable = createAndFillInContextMenuActions(menu, { shouldForwardArgs: true }, result, this.contextMenuService, g => g === 'inline');
menu.dispose();
contextKeyService.dispose();
@@ -313,6 +319,8 @@ export class MainPanel extends ViewletPanel {
getActions: () => secondary,
getActionsContext: () => repository.provider
});
disposable.dispose();
}
private onListSelectionChange(e: IListEvent<ISCMRepository>): void {
@@ -396,14 +404,14 @@ class ResourceGroupRenderer implements IListRenderer<ISCMResourceGroup, Resource
template.actionBar.clear();
template.actionBar.context = group;
const disposables: IDisposable[] = [];
disposables.push(connectPrimaryMenuToInlineActionBar(this.menus.getResourceGroupMenu(group), template.actionBar));
const disposables = new DisposableStore();
disposables.add(connectPrimaryMenuToInlineActionBar(this.menus.getResourceGroupMenu(group), template.actionBar));
const updateCount = () => template.count.setCount(group.elements.length);
group.onDidSplice(updateCount, null, disposables);
disposables.add(group.onDidSplice(updateCount, null));
updateCount();
template.elementDisposable = combinedDisposable(disposables);
template.elementDisposable = disposables;
}
disposeElement(group: ISCMResourceGroup, index: number, template: ResourceGroupTemplate): void {
@@ -489,8 +497,8 @@ class ResourceRenderer implements IListRenderer<ISCMResource, ResourceTemplate>
template.fileLabel.setFile(resource.sourceUri, { fileDecorations: { colors: false, badges: !icon, data: resource.decorations } });
template.actionBar.context = resource;
const disposables: IDisposable[] = [];
disposables.push(connectPrimaryMenuToInlineActionBar(this.menus.getResourceMenu(resource.resourceGroup), template.actionBar));
const disposables = new DisposableStore();
disposables.add(connectPrimaryMenuToInlineActionBar(this.menus.getResourceMenu(resource.resourceGroup), template.actionBar));
toggleClass(template.name, 'strike-through', resource.decorations.strikeThrough);
toggleClass(template.element, 'faded', resource.decorations.faded);
@@ -505,7 +513,7 @@ class ResourceRenderer implements IListRenderer<ISCMResource, ResourceTemplate>
}
template.element.setAttribute('data-tooltip', resource.decorations.tooltip || '');
template.elementDisposable = combinedDisposable(disposables);
template.elementDisposable = disposables;
}
disposeElement(resource: ISCMResource, index: number, template: ResourceTemplate): void {
@@ -602,10 +610,10 @@ class ResourceGroupSplicer {
absoluteToInsert.push(element);
}
const disposable = combinedDisposable([
const disposable = combinedDisposable(
group.onDidChange(() => this.onDidChangeGroup(group)),
group.onDidSplice(splice => this.onDidSpliceGroup(group, splice))
]);
);
itemsToInsert.push({ group, visible, disposable });
}
@@ -699,6 +707,7 @@ export class RepositoryPanel extends ViewletPanel {
private cachedHeight: number | undefined = undefined;
private cachedWidth: number | undefined = undefined;
private cachedScrollTop: number | undefined = undefined;
private inputBoxContainer: HTMLElement;
private inputBox: InputBox;
private listContainer: HTMLElement;
@@ -727,8 +736,8 @@ export class RepositoryPanel extends ViewletPanel {
super(options, keybindingService, contextMenuService, configurationService);
this.menus = instantiationService.createInstance(SCMMenus, this.repository.provider);
this.disposables.push(this.menus);
this.menus.onDidChangeTitle(this._onDidChangeTitleArea.fire, this._onDidChangeTitleArea, this.disposables);
this._register(this.menus);
this._register(this.menus.onDidChangeTitle(this._onDidChangeTitleArea.fire, this._onDidChangeTitleArea));
this.contextKeyService = contextKeyService.createScoped(this.element);
this.contextKeyService.createKey('scmRepository', this.repository);
@@ -736,7 +745,7 @@ export class RepositoryPanel extends ViewletPanel {
render(): void {
super.render();
this.menus.onDidChangeTitle(this.updateActions, this, this.disposables);
this._register(this.menus.onDidChangeTitle(this.updateActions, this));
}
protected renderHeaderTitle(container: HTMLElement): void {
@@ -758,8 +767,8 @@ export class RepositoryPanel extends ViewletPanel {
protected renderBody(container: HTMLElement): void {
const focusTracker = trackFocus(container);
this.disposables.push(focusTracker.onDidFocus(() => this.repository.focus()));
this.disposables.push(focusTracker);
this._register(focusTracker.onDidFocus(() => this.repository.focus()));
this._register(focusTracker);
// Input
this.inputBoxContainer = append(container, $('.scm-editor'));
@@ -789,33 +798,33 @@ export class RepositoryPanel extends ViewletPanel {
this.inputBox = new InputBox(this.inputBoxContainer, this.contextViewService, { flexibleHeight: true });
this.inputBox.setEnabled(this.isBodyVisible());
this.disposables.push(attachInputBoxStyler(this.inputBox, this.themeService));
this.disposables.push(this.inputBox);
this._register(attachInputBoxStyler(this.inputBox, this.themeService));
this._register(this.inputBox);
this.inputBox.onDidChange(triggerValidation, null, this.disposables);
this._register(this.inputBox.onDidChange(triggerValidation, null));
const onKeyUp = domEvent(this.inputBox.inputElement, 'keyup');
const onMouseUp = domEvent(this.inputBox.inputElement, 'mouseup');
Event.any<any>(onKeyUp, onMouseUp)(triggerValidation, null, this.disposables);
this._register(Event.any<any>(onKeyUp, onMouseUp)(triggerValidation, null));
this.inputBox.value = this.repository.input.value;
this.inputBox.onDidChange(value => this.repository.input.value = value, null, this.disposables);
this.repository.input.onDidChange(value => this.inputBox.value = value, null, this.disposables);
this._register(this.inputBox.onDidChange(value => this.repository.input.value = value, null));
this._register(this.repository.input.onDidChange(value => this.inputBox.value = value, null));
updatePlaceholder();
this.repository.input.onDidChangePlaceholder(updatePlaceholder, null, this.disposables);
this.keybindingService.onDidUpdateKeybindings(updatePlaceholder, null, this.disposables);
this._register(this.repository.input.onDidChangePlaceholder(updatePlaceholder, null));
this._register(this.keybindingService.onDidUpdateKeybindings(updatePlaceholder, null));
this.disposables.push(this.inputBox.onDidHeightChange(() => this.layoutBody()));
this._register(this.inputBox.onDidHeightChange(() => this.layoutBody()));
if (this.repository.provider.onDidChangeCommitTemplate) {
this.repository.provider.onDidChangeCommitTemplate(this.updateInputBox, this, this.disposables);
this._register(this.repository.provider.onDidChangeCommitTemplate(this.updateInputBox, this));
}
this.updateInputBox();
// Input box visibility
this.repository.input.onDidChangeVisibility(this.updateInputBoxVisibility, this, this.disposables);
this._register(this.repository.input.onDidChangeVisibility(this.updateInputBoxVisibility, this));
this.updateInputBoxVisibility();
// List
@@ -830,7 +839,7 @@ export class RepositoryPanel extends ViewletPanel {
const actionViewItemProvider = (action: IAction) => this.getActionViewItem(action);
this.listLabels = this.instantiationService.createInstance(ResourceLabels, { onDidChangeVisibility: this.onDidChangeBodyVisibility });
this.disposables.push(this.listLabels);
this._register(this.listLabels);
const renderers = [
new ResourceGroupRenderer(actionViewItemProvider, this.themeService, this.menus),
@@ -843,20 +852,20 @@ export class RepositoryPanel extends ViewletPanel {
horizontalScrolling: false
}) as WorkbenchList<ISCMResourceGroup | ISCMResource>;
Event.chain(this.list.onDidOpen)
this._register(Event.chain(this.list.onDidOpen)
.map(e => e.elements[0])
.filter(e => !!e && isSCMResource(e))
.on(this.open, this, this.disposables);
.on(this.open, this));
Event.chain(this.list.onPin)
this._register(Event.chain(this.list.onPin)
.map(e => e.elements[0])
.filter(e => !!e && isSCMResource(e))
.on(this.pin, this, this.disposables);
.on(this.pin, this));
this.list.onContextMenu(this.onListContextMenu, this, this.disposables);
this.disposables.push(this.list);
this._register(this.list.onContextMenu(this.onListContextMenu, this));
this._register(this.list);
this.viewModel.onDidChangeVisibility(this.onDidChangeVisibility, this, this.disposables);
this._register(this.viewModel.onDidChangeVisibility(this.onDidChangeVisibility, this));
this.onDidChangeVisibility(this.viewModel.isVisible());
this.onDidChangeBodyVisibility(visible => this.inputBox.setEnabled(visible));
}
@@ -866,6 +875,7 @@ export class RepositoryPanel extends ViewletPanel {
const listSplicer = new ResourceGroupSplicer(this.repository.provider.groups, this.list);
this.visibilityDisposables.push(listSplicer);
} else {
this.cachedScrollTop = this.list.scrollTop;
this.visibilityDisposables = dispose(this.visibilityDisposables);
}
}
@@ -894,6 +904,13 @@ export class RepositoryPanel extends ViewletPanel {
this.listContainer.style.height = `${height}px`;
this.list.layout(height, width);
}
if (this.cachedScrollTop !== undefined && this.list.scrollTop !== this.cachedScrollTop) {
this.list.scrollTop = Math.min(this.cachedScrollTop, this.list.scrollHeight);
// Applying the cached scroll position just once until the next leave.
// This, also, avoids the scrollbar to flicker when resizing the sidebar.
this.cachedScrollTop = undefined;
}
}
focus(): void {
@@ -1106,15 +1123,15 @@ export class SCMViewlet extends ViewContainerViewlet implements IViewModel {
super(VIEWLET_ID, SCMViewlet.STATE_KEY, true, configurationService, layoutService, telemetryService, storageService, instantiationService, themeService, contextMenuService, extensionService, contextService);
this.menus = instantiationService.createInstance(SCMMenus, undefined);
this.menus.onDidChangeTitle(this.updateTitleArea, this, this.toDispose);
this._register(this.menus.onDidChangeTitle(this.updateTitleArea, this));
this.message = $('.empty-message', { tabIndex: 0 }, localize('no open repo', "No source control providers registered."));
configurationService.onDidChangeConfiguration(e => {
this._register(configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('scm.alwaysShowProviders')) {
this.onDidChangeRepositories();
}
}, this.toDispose);
}));
}
create(parent: HTMLElement): void {
@@ -1124,8 +1141,8 @@ export class SCMViewlet extends ViewContainerViewlet implements IViewModel {
addClasses(parent, 'scm-viewlet', 'empty');
append(parent, this.message);
this.scmService.onDidAddRepository(this.onDidAddRepository, this, this.toDispose);
this.scmService.onDidRemoveRepository(this.onDidRemoveRepository, this, this.toDispose);
this._register(this.scmService.onDidAddRepository(this.onDidAddRepository, this));
this._register(this.scmService.onDidRemoveRepository(this.onDidRemoveRepository, this));
this.scmService.repositories.forEach(r => this.onDidAddRepository(r));
}