mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-31 01:00:29 -04:00
This reverts commit d15a3fcc98.
This commit is contained in:
@@ -7,7 +7,7 @@ import * as nls from 'vs/nls';
|
||||
|
||||
import 'vs/css!./media/dirtydiffDecorator';
|
||||
import { ThrottledDelayer, first } from 'vs/base/common/async';
|
||||
import { IDisposable, dispose, toDisposable, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, dispose, toDisposable, Disposable, combinedDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import * as ext from 'vs/workbench/common/contributions';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
@@ -184,7 +184,7 @@ class DirtyDiffWidget extends PeekViewWidget {
|
||||
) {
|
||||
super(editor, { isResizeable: true, frameWidth: 1, keepEditorSelection: true });
|
||||
|
||||
this._disposables.add(themeService.onThemeChange(this._applyTheme, this));
|
||||
themeService.onThemeChange(this._applyTheme, this, this._disposables);
|
||||
this._applyTheme(themeService.getTheme());
|
||||
|
||||
this.contextKeyService = contextKeyService.createScoped();
|
||||
@@ -199,7 +199,7 @@ class DirtyDiffWidget extends PeekViewWidget {
|
||||
}
|
||||
this.setTitle(this.title);
|
||||
|
||||
this._disposables.add(model.onDidChange(this.renderTitle, this));
|
||||
model.onDidChange(this.renderTitle, this, this._disposables);
|
||||
}
|
||||
|
||||
showChange(index: number): void {
|
||||
@@ -253,8 +253,8 @@ class DirtyDiffWidget extends PeekViewWidget {
|
||||
const previous = this.instantiationService.createInstance(UIEditorAction, this.editor, new ShowPreviousChangeAction(), 'show-previous-change chevron-up');
|
||||
const next = this.instantiationService.createInstance(UIEditorAction, this.editor, new ShowNextChangeAction(), 'show-next-change chevron-down');
|
||||
|
||||
this._disposables.add(previous);
|
||||
this._disposables.add(next);
|
||||
this._disposables.push(previous);
|
||||
this._disposables.push(next);
|
||||
this._actionbarWidget.push([previous, next], { label: false, icon: true });
|
||||
|
||||
const actions: IAction[] = [];
|
||||
@@ -554,7 +554,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
}
|
||||
});
|
||||
|
||||
export class DirtyDiffController extends Disposable implements IEditorContribution {
|
||||
export class DirtyDiffController implements IEditorContribution {
|
||||
|
||||
private static readonly ID = 'editor.contrib.dirtydiff';
|
||||
|
||||
@@ -571,20 +571,20 @@ export class DirtyDiffController extends Disposable implements IEditorContributi
|
||||
private session: IDisposable = Disposable.None;
|
||||
private mouseDownInfo: { lineNumber: number } | null = null;
|
||||
private enabled = false;
|
||||
private disposables: IDisposable[] = [];
|
||||
|
||||
constructor(
|
||||
private editor: ICodeEditor,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService
|
||||
) {
|
||||
super();
|
||||
this.enabled = !contextKeyService.getContextKeyValue('isInDiffEditor');
|
||||
|
||||
if (this.enabled) {
|
||||
this.isDirtyDiffVisible = isDirtyDiffVisible.bindTo(contextKeyService);
|
||||
this._register(editor.onMouseDown(e => this.onEditorMouseDown(e)));
|
||||
this._register(editor.onMouseUp(e => this.onEditorMouseUp(e)));
|
||||
this._register(editor.onDidChangeModel(() => this.close()));
|
||||
this.disposables.push(editor.onMouseDown(e => this.onEditorMouseDown(e)));
|
||||
this.disposables.push(editor.onMouseUp(e => this.onEditorMouseUp(e)));
|
||||
this.disposables.push(editor.onDidChangeModel(() => this.close()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -674,20 +674,22 @@ export class DirtyDiffController extends Disposable implements IEditorContributi
|
||||
this.widget = this.instantiationService.createInstance(DirtyDiffWidget, this.editor, model);
|
||||
this.isDirtyDiffVisible.set(true);
|
||||
|
||||
const disposables = new DisposableStore();
|
||||
disposables.add(Event.once(this.widget.onDidClose)(this.close, this));
|
||||
disposables.add(model.onDidChange(this.onDidModelChange, this));
|
||||
const disposables: IDisposable[] = [];
|
||||
Event.once(this.widget.onDidClose)(this.close, this, disposables);
|
||||
model.onDidChange(this.onDidModelChange, this, disposables);
|
||||
|
||||
disposables.add(this.widget);
|
||||
disposables.add(toDisposable(() => {
|
||||
this.model = null;
|
||||
this.widget = null;
|
||||
this.currentIndex = -1;
|
||||
this.isDirtyDiffVisible.set(false);
|
||||
this.editor.focus();
|
||||
}));
|
||||
disposables.push(
|
||||
this.widget,
|
||||
toDisposable(() => {
|
||||
this.model = null;
|
||||
this.widget = null;
|
||||
this.currentIndex = -1;
|
||||
this.isDirtyDiffVisible.set(false);
|
||||
this.editor.focus();
|
||||
})
|
||||
);
|
||||
|
||||
this.session = disposables;
|
||||
this.session = combinedDisposable(disposables);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -806,6 +808,10 @@ export class DirtyDiffController extends Disposable implements IEditorContributi
|
||||
|
||||
return model.changes;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.disposables = dispose(this.disposables);
|
||||
}
|
||||
}
|
||||
|
||||
export const editorGutterModifiedBackground = registerColor('editorGutter.modifiedBackground', {
|
||||
@@ -831,7 +837,7 @@ export const overviewRulerModifiedForeground = registerColor('editorOverviewRule
|
||||
export const overviewRulerAddedForeground = registerColor('editorOverviewRuler.addedForeground', { dark: overviewRulerDefault, light: overviewRulerDefault, hc: overviewRulerDefault }, nls.localize('overviewRulerAddedForeground', 'Overview ruler marker color for added content.'));
|
||||
export const overviewRulerDeletedForeground = registerColor('editorOverviewRuler.deletedForeground', { dark: overviewRulerDefault, light: overviewRulerDefault, hc: overviewRulerDefault }, nls.localize('overviewRulerDeletedForeground', 'Overview ruler marker color for deleted content.'));
|
||||
|
||||
class DirtyDiffDecorator extends Disposable {
|
||||
class DirtyDiffDecorator {
|
||||
|
||||
static createDecoration(className: string, foregroundColor: string, options: { gutter: boolean, overview: boolean, isWholeLine: boolean }): ModelDecorationOptions {
|
||||
const decorationOptions: IModelDecorationOptions = {
|
||||
@@ -856,6 +862,7 @@ class DirtyDiffDecorator extends Disposable {
|
||||
private addedOptions: ModelDecorationOptions;
|
||||
private deletedOptions: ModelDecorationOptions;
|
||||
private decorations: string[] = [];
|
||||
private disposables: IDisposable[] = [];
|
||||
private editorModel: ITextModel | null;
|
||||
|
||||
constructor(
|
||||
@@ -863,7 +870,6 @@ class DirtyDiffDecorator extends Disposable {
|
||||
private model: DirtyDiffModel,
|
||||
@IConfigurationService configurationService: IConfigurationService
|
||||
) {
|
||||
super();
|
||||
this.editorModel = editorModel;
|
||||
const decorations = configurationService.getValue<string>('scm.diffDecorations');
|
||||
const gutter = decorations === 'all' || decorations === 'gutter';
|
||||
@@ -874,7 +880,7 @@ class DirtyDiffDecorator extends Disposable {
|
||||
this.addedOptions = DirtyDiffDecorator.createDecoration('dirty-diff-added', overviewRulerAddedForeground, options);
|
||||
this.deletedOptions = DirtyDiffDecorator.createDecoration('dirty-diff-deleted', overviewRulerDeletedForeground, { ...options, isWholeLine: false });
|
||||
|
||||
this._register(model.onDidChange(this.onDidChange, this));
|
||||
model.onDidChange(this.onDidChange, this, this.disposables);
|
||||
}
|
||||
|
||||
private onDidChange(): void {
|
||||
@@ -918,7 +924,7 @@ class DirtyDiffDecorator extends Disposable {
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
super.dispose();
|
||||
this.disposables = dispose(this.disposables);
|
||||
|
||||
if (this.editorModel && !this.editorModel.isDisposed()) {
|
||||
this.editorModel.deltaDecorations(this.decorations, []);
|
||||
@@ -951,7 +957,7 @@ function compareChanges(a: IChange, b: IChange): number {
|
||||
return a.originalEndLineNumber - b.originalEndLineNumber;
|
||||
}
|
||||
|
||||
export class DirtyDiffModel extends Disposable {
|
||||
export class DirtyDiffModel {
|
||||
|
||||
private _originalModel: ITextModel | null;
|
||||
get original(): ITextModel | null { return this._originalModel; }
|
||||
@@ -959,8 +965,9 @@ export class DirtyDiffModel extends Disposable {
|
||||
|
||||
private diffDelayer: ThrottledDelayer<IChange[] | null> | null;
|
||||
private _originalURIPromise?: Promise<URI | null>;
|
||||
private repositoryDisposables = new Set<IDisposable>();
|
||||
private readonly originalModelDisposables = this._register(new DisposableStore());
|
||||
private repositoryDisposables = new Set<IDisposable[]>();
|
||||
private originalModelDisposables: IDisposable[] = [];
|
||||
private disposables: IDisposable[] = [];
|
||||
|
||||
private _onDidChange = new Emitter<ISplice<IChange>[]>();
|
||||
readonly onDidChange: Event<ISplice<IChange>[]> = this._onDidChange.event;
|
||||
@@ -978,28 +985,27 @@ export class DirtyDiffModel extends Disposable {
|
||||
@IEditorWorkerService private readonly editorWorkerService: IEditorWorkerService,
|
||||
@ITextModelService private readonly textModelResolverService: ITextModelService
|
||||
) {
|
||||
super();
|
||||
this._editorModel = editorModel;
|
||||
this.diffDelayer = new ThrottledDelayer<IChange[]>(200);
|
||||
|
||||
this._register(editorModel.onDidChangeContent(() => this.triggerDiff()));
|
||||
this._register(scmService.onDidAddRepository(this.onDidAddRepository, this));
|
||||
this.disposables.push(editorModel.onDidChangeContent(() => this.triggerDiff()));
|
||||
scmService.onDidAddRepository(this.onDidAddRepository, this, this.disposables);
|
||||
scmService.repositories.forEach(r => this.onDidAddRepository(r));
|
||||
|
||||
this.triggerDiff();
|
||||
}
|
||||
|
||||
private onDidAddRepository(repository: ISCMRepository): void {
|
||||
const disposables = new DisposableStore();
|
||||
const disposables: IDisposable[] = [];
|
||||
|
||||
this.repositoryDisposables.add(disposables);
|
||||
disposables.add(toDisposable(() => this.repositoryDisposables.delete(disposables)));
|
||||
disposables.push(toDisposable(() => this.repositoryDisposables.delete(disposables)));
|
||||
|
||||
const onDidChange = Event.any(repository.provider.onDidChange, repository.provider.onDidChangeResources);
|
||||
disposables.add(onDidChange(this.triggerDiff, this));
|
||||
onDidChange(this.triggerDiff, this, disposables);
|
||||
|
||||
const onDidRemoveThis = Event.filter(this.scmService.onDidRemoveRepository, r => r === repository);
|
||||
disposables.add(onDidRemoveThis(() => dispose(disposables), null));
|
||||
onDidRemoveThis(() => dispose(disposables), null, disposables);
|
||||
|
||||
this.triggerDiff();
|
||||
}
|
||||
@@ -1069,9 +1075,12 @@ export class DirtyDiffModel extends Disposable {
|
||||
|
||||
this._originalModel = ref.object.textEditorModel;
|
||||
|
||||
this.originalModelDisposables.clear();
|
||||
this.originalModelDisposables.add(ref);
|
||||
this.originalModelDisposables.add(ref.object.textEditorModel.onDidChangeContent(() => this.triggerDiff()));
|
||||
const originalModelDisposables: IDisposable[] = [];
|
||||
originalModelDisposables.push(ref);
|
||||
originalModelDisposables.push(ref.object.textEditorModel.onDidChangeContent(() => this.triggerDiff()));
|
||||
|
||||
dispose(this.originalModelDisposables);
|
||||
this.originalModelDisposables = originalModelDisposables;
|
||||
|
||||
return originalUri;
|
||||
});
|
||||
@@ -1128,7 +1137,8 @@ export class DirtyDiffModel extends Disposable {
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
super.dispose();
|
||||
this.originalModelDisposables = dispose(this.originalModelDisposables);
|
||||
this.disposables = dispose(this.disposables);
|
||||
|
||||
this._editorModel = null;
|
||||
this._originalModel = null;
|
||||
@@ -1153,25 +1163,25 @@ class DirtyDiffItem {
|
||||
}
|
||||
}
|
||||
|
||||
export class DirtyDiffWorkbenchController extends Disposable implements ext.IWorkbenchContribution, IModelRegistry {
|
||||
export class DirtyDiffWorkbenchController implements ext.IWorkbenchContribution, IModelRegistry {
|
||||
|
||||
private enabled = false;
|
||||
private models: ITextModel[] = [];
|
||||
private items: { [modelId: string]: DirtyDiffItem; } = Object.create(null);
|
||||
private transientDisposables: IDisposable[] = [];
|
||||
private stylesheet: HTMLStyleElement;
|
||||
private disposables: IDisposable[] = [];
|
||||
|
||||
constructor(
|
||||
@IEditorService private readonly editorService: IEditorService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||
) {
|
||||
super();
|
||||
this.stylesheet = createStyleSheet();
|
||||
this._register(toDisposable(() => this.stylesheet.parentElement!.removeChild(this.stylesheet)));
|
||||
this.disposables.push(toDisposable(() => this.stylesheet.parentElement!.removeChild(this.stylesheet)));
|
||||
|
||||
const onDidChangeConfiguration = Event.filter(configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.diffDecorations'));
|
||||
this._register(onDidChangeConfiguration(this.onDidChangeConfiguration, this));
|
||||
onDidChangeConfiguration(this.onDidChangeConfiguration, this, this.disposables);
|
||||
this.onDidChangeConfiguration();
|
||||
|
||||
const onDidChangeDiffWidthConfiguration = Event.filter(configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.diffDecorationsGutterWidth'));
|
||||
@@ -1274,7 +1284,7 @@ export class DirtyDiffWorkbenchController extends Disposable implements ext.IWor
|
||||
|
||||
dispose(): void {
|
||||
this.disable();
|
||||
super.dispose();
|
||||
this.disposables = dispose(this.disposables);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { basename } from 'vs/base/common/resources';
|
||||
import { IDisposable, dispose, Disposable, DisposableStore, combinedDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, dispose, Disposable, combinedDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { VIEWLET_ID, ISCMService, ISCMRepository } from 'vs/workbench/contrib/scm/common/scm';
|
||||
import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/common/activity';
|
||||
@@ -46,7 +46,7 @@ export class StatusUpdater implements IWorkbenchContribution {
|
||||
this.render();
|
||||
});
|
||||
|
||||
const disposable = combinedDisposable(changeDisposable, removeDisposable);
|
||||
const disposable = combinedDisposable([changeDisposable, removeDisposable]);
|
||||
this.disposables.push(disposable);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ export class StatusBarController implements IWorkbenchContribution {
|
||||
}
|
||||
});
|
||||
|
||||
const disposable = combinedDisposable(changeDisposable, removeDisposable);
|
||||
const disposable = combinedDisposable([changeDisposable, removeDisposable]);
|
||||
this.disposables.push(disposable);
|
||||
|
||||
if (!this.focusedRepository) {
|
||||
@@ -187,17 +187,14 @@ export class StatusBarController implements IWorkbenchContribution {
|
||||
? `${basename(repository.provider.rootUri)} (${repository.provider.label})`
|
||||
: repository.provider.label;
|
||||
|
||||
const disposables = new DisposableStore();
|
||||
for (const c of commands) {
|
||||
disposables.add(this.statusbarService.addEntry({
|
||||
text: c.title,
|
||||
tooltip: `${label} - ${c.tooltip}`,
|
||||
command: c.id,
|
||||
arguments: c.arguments
|
||||
}, 'status.scm', localize('status.scm', "Source Control"), MainThreadStatusBarAlignment.LEFT, 10000));
|
||||
}
|
||||
const disposables = commands.map(c => this.statusbarService.addEntry({
|
||||
text: c.title,
|
||||
tooltip: `${label} - ${c.tooltip}`,
|
||||
command: c.id,
|
||||
arguments: c.arguments
|
||||
}, MainThreadStatusBarAlignment.LEFT, 10000));
|
||||
|
||||
this.statusBarDisposable = disposables;
|
||||
this.statusBarDisposable = combinedDisposable(disposables);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
|
||||
@@ -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, Disposable, DisposableStore, combinedDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, dispose, combinedDisposable, Disposable } 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';
|
||||
@@ -162,14 +162,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 = new DisposableStore();
|
||||
const disposables: IDisposable[] = [];
|
||||
|
||||
if (repository.provider.rootUri) {
|
||||
templateData.title.textContent = basename(repository.provider.rootUri);
|
||||
@@ -181,7 +181,7 @@ class ProviderRenderer implements IListRenderer<ISCMRepository, RepositoryTempla
|
||||
|
||||
const actions: IAction[] = [];
|
||||
const disposeActions = () => dispose(actions);
|
||||
disposables.add({ dispose: disposeActions });
|
||||
disposables.push({ dispose: disposeActions });
|
||||
|
||||
const update = () => {
|
||||
disposeActions();
|
||||
@@ -198,10 +198,10 @@ class ProviderRenderer implements IListRenderer<ISCMRepository, RepositoryTempla
|
||||
this._onDidRenderElement.fire(repository);
|
||||
};
|
||||
|
||||
disposables.add(repository.provider.onDidChange(update, null));
|
||||
repository.provider.onDidChange(update, null, disposables);
|
||||
update();
|
||||
|
||||
templateData.disposable = disposables;
|
||||
templateData.disposable = combinedDisposable(disposables);
|
||||
}
|
||||
|
||||
disposeTemplate(templateData: RepositoryTemplateData): void {
|
||||
@@ -241,23 +241,23 @@ export class MainPanel extends ViewletPanel {
|
||||
horizontalScrolling: false
|
||||
}) as WorkbenchList<ISCMRepository>;
|
||||
|
||||
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));
|
||||
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(this.viewModel.onDidChangeVisibleRepositories(this.updateListSelection, this));
|
||||
this.viewModel.onDidChangeVisibleRepositories(this.updateListSelection, this, this.disposables);
|
||||
|
||||
this._register(this.viewModel.onDidSplice(({ index, deleteCount, elements }) => this.splice(index, deleteCount, elements), null));
|
||||
this.viewModel.onDidSplice(({ index, deleteCount, elements }) => this.splice(index, deleteCount, elements), null, this.disposables);
|
||||
this.splice(0, 0, this.viewModel.repositories);
|
||||
|
||||
this._register(this.list);
|
||||
this.disposables.push(this.list);
|
||||
|
||||
this._register(this.configurationService.onDidChangeConfiguration(e => {
|
||||
this.configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration('scm.providers.visible')) {
|
||||
this.updateBodySize();
|
||||
}
|
||||
}));
|
||||
}, this.disposables);
|
||||
|
||||
this.updateListSelection();
|
||||
}
|
||||
@@ -396,14 +396,14 @@ class ResourceGroupRenderer implements IListRenderer<ISCMResourceGroup, Resource
|
||||
template.actionBar.clear();
|
||||
template.actionBar.context = group;
|
||||
|
||||
const disposables = new DisposableStore();
|
||||
disposables.add(connectPrimaryMenuToInlineActionBar(this.menus.getResourceGroupMenu(group), template.actionBar));
|
||||
const disposables: IDisposable[] = [];
|
||||
disposables.push(connectPrimaryMenuToInlineActionBar(this.menus.getResourceGroupMenu(group), template.actionBar));
|
||||
|
||||
const updateCount = () => template.count.setCount(group.elements.length);
|
||||
disposables.add(group.onDidSplice(updateCount, null));
|
||||
group.onDidSplice(updateCount, null, disposables);
|
||||
updateCount();
|
||||
|
||||
template.elementDisposable = disposables;
|
||||
template.elementDisposable = combinedDisposable(disposables);
|
||||
}
|
||||
|
||||
disposeElement(group: ISCMResourceGroup, index: number, template: ResourceGroupTemplate): void {
|
||||
@@ -489,8 +489,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 = new DisposableStore();
|
||||
disposables.add(connectPrimaryMenuToInlineActionBar(this.menus.getResourceMenu(resource.resourceGroup), template.actionBar));
|
||||
const disposables: IDisposable[] = [];
|
||||
disposables.push(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 +505,7 @@ class ResourceRenderer implements IListRenderer<ISCMResource, ResourceTemplate>
|
||||
}
|
||||
|
||||
template.element.setAttribute('data-tooltip', resource.decorations.tooltip || '');
|
||||
template.elementDisposable = disposables;
|
||||
template.elementDisposable = combinedDisposable(disposables);
|
||||
}
|
||||
|
||||
disposeElement(resource: ISCMResource, index: number, template: ResourceTemplate): void {
|
||||
@@ -602,10 +602,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,7 +699,6 @@ 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;
|
||||
@@ -728,8 +727,8 @@ export class RepositoryPanel extends ViewletPanel {
|
||||
super(options, keybindingService, contextMenuService, configurationService);
|
||||
|
||||
this.menus = instantiationService.createInstance(SCMMenus, this.repository.provider);
|
||||
this._register(this.menus);
|
||||
this._register(this.menus.onDidChangeTitle(this._onDidChangeTitleArea.fire, this._onDidChangeTitleArea));
|
||||
this.disposables.push(this.menus);
|
||||
this.menus.onDidChangeTitle(this._onDidChangeTitleArea.fire, this._onDidChangeTitleArea, this.disposables);
|
||||
|
||||
this.contextKeyService = contextKeyService.createScoped(this.element);
|
||||
this.contextKeyService.createKey('scmRepository', this.repository);
|
||||
@@ -737,7 +736,7 @@ export class RepositoryPanel extends ViewletPanel {
|
||||
|
||||
render(): void {
|
||||
super.render();
|
||||
this._register(this.menus.onDidChangeTitle(this.updateActions, this));
|
||||
this.menus.onDidChangeTitle(this.updateActions, this, this.disposables);
|
||||
}
|
||||
|
||||
protected renderHeaderTitle(container: HTMLElement): void {
|
||||
@@ -759,8 +758,8 @@ export class RepositoryPanel extends ViewletPanel {
|
||||
|
||||
protected renderBody(container: HTMLElement): void {
|
||||
const focusTracker = trackFocus(container);
|
||||
this._register(focusTracker.onDidFocus(() => this.repository.focus()));
|
||||
this._register(focusTracker);
|
||||
this.disposables.push(focusTracker.onDidFocus(() => this.repository.focus()));
|
||||
this.disposables.push(focusTracker);
|
||||
|
||||
// Input
|
||||
this.inputBoxContainer = append(container, $('.scm-editor'));
|
||||
@@ -790,33 +789,33 @@ export class RepositoryPanel extends ViewletPanel {
|
||||
|
||||
this.inputBox = new InputBox(this.inputBoxContainer, this.contextViewService, { flexibleHeight: true });
|
||||
this.inputBox.setEnabled(this.isBodyVisible());
|
||||
this._register(attachInputBoxStyler(this.inputBox, this.themeService));
|
||||
this._register(this.inputBox);
|
||||
this.disposables.push(attachInputBoxStyler(this.inputBox, this.themeService));
|
||||
this.disposables.push(this.inputBox);
|
||||
|
||||
this._register(this.inputBox.onDidChange(triggerValidation, null));
|
||||
this.inputBox.onDidChange(triggerValidation, null, this.disposables);
|
||||
|
||||
const onKeyUp = domEvent(this.inputBox.inputElement, 'keyup');
|
||||
const onMouseUp = domEvent(this.inputBox.inputElement, 'mouseup');
|
||||
this._register(Event.any<any>(onKeyUp, onMouseUp)(triggerValidation, null));
|
||||
Event.any<any>(onKeyUp, onMouseUp)(triggerValidation, null, this.disposables);
|
||||
|
||||
this.inputBox.value = this.repository.input.value;
|
||||
this._register(this.inputBox.onDidChange(value => this.repository.input.value = value, null));
|
||||
this._register(this.repository.input.onDidChange(value => this.inputBox.value = value, null));
|
||||
this.inputBox.onDidChange(value => this.repository.input.value = value, null, this.disposables);
|
||||
this.repository.input.onDidChange(value => this.inputBox.value = value, null, this.disposables);
|
||||
|
||||
updatePlaceholder();
|
||||
this._register(this.repository.input.onDidChangePlaceholder(updatePlaceholder, null));
|
||||
this._register(this.keybindingService.onDidUpdateKeybindings(updatePlaceholder, null));
|
||||
this.repository.input.onDidChangePlaceholder(updatePlaceholder, null, this.disposables);
|
||||
this.keybindingService.onDidUpdateKeybindings(updatePlaceholder, null, this.disposables);
|
||||
|
||||
this._register(this.inputBox.onDidHeightChange(() => this.layoutBody()));
|
||||
this.disposables.push(this.inputBox.onDidHeightChange(() => this.layoutBody()));
|
||||
|
||||
if (this.repository.provider.onDidChangeCommitTemplate) {
|
||||
this._register(this.repository.provider.onDidChangeCommitTemplate(this.updateInputBox, this));
|
||||
this.repository.provider.onDidChangeCommitTemplate(this.updateInputBox, this, this.disposables);
|
||||
}
|
||||
|
||||
this.updateInputBox();
|
||||
|
||||
// Input box visibility
|
||||
this._register(this.repository.input.onDidChangeVisibility(this.updateInputBoxVisibility, this));
|
||||
this.repository.input.onDidChangeVisibility(this.updateInputBoxVisibility, this, this.disposables);
|
||||
this.updateInputBoxVisibility();
|
||||
|
||||
// List
|
||||
@@ -831,7 +830,7 @@ export class RepositoryPanel extends ViewletPanel {
|
||||
const actionViewItemProvider = (action: IAction) => this.getActionViewItem(action);
|
||||
|
||||
this.listLabels = this.instantiationService.createInstance(ResourceLabels, { onDidChangeVisibility: this.onDidChangeBodyVisibility });
|
||||
this._register(this.listLabels);
|
||||
this.disposables.push(this.listLabels);
|
||||
|
||||
const renderers = [
|
||||
new ResourceGroupRenderer(actionViewItemProvider, this.themeService, this.menus),
|
||||
@@ -844,20 +843,20 @@ export class RepositoryPanel extends ViewletPanel {
|
||||
horizontalScrolling: false
|
||||
}) as WorkbenchList<ISCMResourceGroup | ISCMResource>;
|
||||
|
||||
this._register(Event.chain(this.list.onDidOpen)
|
||||
Event.chain(this.list.onDidOpen)
|
||||
.map(e => e.elements[0])
|
||||
.filter(e => !!e && isSCMResource(e))
|
||||
.on(this.open, this));
|
||||
.on(this.open, this, this.disposables);
|
||||
|
||||
this._register(Event.chain(this.list.onPin)
|
||||
Event.chain(this.list.onPin)
|
||||
.map(e => e.elements[0])
|
||||
.filter(e => !!e && isSCMResource(e))
|
||||
.on(this.pin, this));
|
||||
.on(this.pin, this, this.disposables);
|
||||
|
||||
this._register(this.list.onContextMenu(this.onListContextMenu, this));
|
||||
this._register(this.list);
|
||||
this.list.onContextMenu(this.onListContextMenu, this, this.disposables);
|
||||
this.disposables.push(this.list);
|
||||
|
||||
this._register(this.viewModel.onDidChangeVisibility(this.onDidChangeVisibility, this));
|
||||
this.viewModel.onDidChangeVisibility(this.onDidChangeVisibility, this, this.disposables);
|
||||
this.onDidChangeVisibility(this.viewModel.isVisible());
|
||||
this.onDidChangeBodyVisibility(visible => this.inputBox.setEnabled(visible));
|
||||
}
|
||||
@@ -867,7 +866,6 @@ 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);
|
||||
}
|
||||
}
|
||||
@@ -896,13 +894,6 @@ 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 {
|
||||
@@ -1115,15 +1106,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._register(this.menus.onDidChangeTitle(this.updateTitleArea, this));
|
||||
this.menus.onDidChangeTitle(this.updateTitleArea, this, this.toDispose);
|
||||
|
||||
this.message = $('.empty-message', { tabIndex: 0 }, localize('no open repo', "No source control providers registered."));
|
||||
|
||||
this._register(configurationService.onDidChangeConfiguration(e => {
|
||||
configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration('scm.alwaysShowProviders')) {
|
||||
this.onDidChangeRepositories();
|
||||
}
|
||||
}));
|
||||
}, this.toDispose);
|
||||
}
|
||||
|
||||
create(parent: HTMLElement): void {
|
||||
@@ -1133,8 +1124,8 @@ export class SCMViewlet extends ViewContainerViewlet implements IViewModel {
|
||||
addClasses(parent, 'scm-viewlet', 'empty');
|
||||
append(parent, this.message);
|
||||
|
||||
this._register(this.scmService.onDidAddRepository(this.onDidAddRepository, this));
|
||||
this._register(this.scmService.onDidRemoveRepository(this.onDidRemoveRepository, this));
|
||||
this.scmService.onDidAddRepository(this.onDidAddRepository, this, this.toDispose);
|
||||
this.scmService.onDidRemoveRepository(this.onDidRemoveRepository, this, this.toDispose);
|
||||
this.scmService.repositories.forEach(r => this.onDidAddRepository(r));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user