mirror of
https://github.com/Microsoft/vscode
synced 2024-09-29 07:51:27 +00:00
SCM - 💄 history provider observables cleanup (#221474)
This commit is contained in:
parent
665dd6371d
commit
31f831310c
|
@ -83,16 +83,16 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
|
|||
this.currentHistoryItemGroup = {
|
||||
id: `refs/heads/${this.repository.HEAD.name ?? ''}`,
|
||||
name: this.repository.HEAD.name ?? '',
|
||||
revision: this.repository.HEAD.commit ?? '',
|
||||
revision: this.repository.HEAD.commit,
|
||||
remote: this.repository.HEAD.upstream ? {
|
||||
id: `refs/remotes/${this.repository.HEAD.upstream.remote}/${this.repository.HEAD.upstream.name}`,
|
||||
name: `${this.repository.HEAD.upstream.remote}/${this.repository.HEAD.upstream.name}`,
|
||||
revision: this.repository.HEAD.upstream.commit ?? ''
|
||||
revision: this.repository.HEAD.upstream.commit
|
||||
} : undefined,
|
||||
base: mergeBase ? {
|
||||
id: `refs/remotes/${mergeBase.remote}/${mergeBase.name}`,
|
||||
name: `${mergeBase.remote}/${mergeBase.name}`,
|
||||
revision: mergeBase.commit ?? ''
|
||||
revision: mergeBase.commit
|
||||
} : undefined
|
||||
};
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { Barrier } from 'vs/base/common/async';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { derivedOpts, observableValue, observableValueOpts } from 'vs/base/common/observable';
|
||||
import { derived, observableValue, observableValueOpts } from 'vs/base/common/observable';
|
||||
import { IDisposable, DisposableStore, combinedDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ISCMService, ISCMRepository, ISCMProvider, ISCMResource, ISCMResourceGroup, ISCMResourceDecorations, IInputValidation, ISCMViewService, InputValidationType, ISCMActionButtonDescriptor } from 'vs/workbench/contrib/scm/common/scm';
|
||||
import { ExtHostContext, MainThreadSCMShape, ExtHostSCMShape, SCMProviderFeatures, SCMRawResourceSplices, SCMGroupFeatures, MainContext, SCMHistoryItemGroupDto, SCMHistoryItemDto } from '../common/extHost.protocol';
|
||||
|
@ -17,7 +17,7 @@ import { MarshalledId } from 'vs/base/common/marshallingIds';
|
|||
import { ThemeIcon } from 'vs/base/common/themables';
|
||||
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
||||
import { IQuickDiffService, QuickDiffProvider } from 'vs/workbench/contrib/scm/common/quickDiff';
|
||||
import { ISCMHistoryItem, ISCMHistoryItemChange, ISCMHistoryItemGroup, ISCMHistoryItemGroupWithRevision, ISCMHistoryOptions, ISCMHistoryProvider } from 'vs/workbench/contrib/scm/common/history';
|
||||
import { ISCMHistoryItem, ISCMHistoryItemChange, ISCMHistoryItemGroup, ISCMHistoryOptions, ISCMHistoryProvider } from 'vs/workbench/contrib/scm/common/history';
|
||||
import { ResourceTree } from 'vs/base/common/resourceTree';
|
||||
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
|
@ -49,12 +49,6 @@ function toISCMHistoryItem(historyItemDto: SCMHistoryItemDto): ISCMHistoryItem {
|
|||
return { ...historyItemDto, icon, labels };
|
||||
}
|
||||
|
||||
function historyItemGroupEquals(a: ISCMHistoryItemGroup | undefined, b: ISCMHistoryItemGroup | undefined): boolean {
|
||||
return a?.id === b?.id && a?.name === b?.name &&
|
||||
a?.base?.id === b?.base?.id && a?.base?.name === b?.base?.name &&
|
||||
a?.remote?.id === b?.remote?.id && a?.remote?.name === b?.remote?.name;
|
||||
}
|
||||
|
||||
class SCMInputBoxContentProvider extends Disposable implements ITextModelContentProvider {
|
||||
constructor(
|
||||
textModelService: ITextModelService,
|
||||
|
@ -171,26 +165,18 @@ class MainThreadSCMHistoryProvider implements ISCMHistoryProvider {
|
|||
private _onDidChangeCurrentHistoryItemGroup = new Emitter<void>();
|
||||
readonly onDidChangeCurrentHistoryItemGroup = this._onDidChangeCurrentHistoryItemGroup.event;
|
||||
|
||||
private _currentHistoryItemGroup: ISCMHistoryItemGroupWithRevision | undefined;
|
||||
get currentHistoryItemGroup(): ISCMHistoryItemGroupWithRevision | undefined { return this._currentHistoryItemGroup; }
|
||||
set currentHistoryItemGroup(historyItemGroup: ISCMHistoryItemGroupWithRevision | undefined) {
|
||||
private _currentHistoryItemGroup: ISCMHistoryItemGroup | undefined;
|
||||
get currentHistoryItemGroup(): ISCMHistoryItemGroup | undefined { return this._currentHistoryItemGroup; }
|
||||
set currentHistoryItemGroup(historyItemGroup: ISCMHistoryItemGroup | undefined) {
|
||||
this._currentHistoryItemGroup = historyItemGroup;
|
||||
this._onDidChangeCurrentHistoryItemGroup.fire();
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes when the id/name changes for the current, remote, or base history item group
|
||||
*/
|
||||
private readonly _currentHistoryItemGroupObs = derivedOpts<ISCMHistoryItemGroup | undefined>({
|
||||
owner: this, equalsFn: historyItemGroupEquals,
|
||||
}, reader => this._currentHistoryItemGroupWithRevisionObs.read(reader));
|
||||
get currentHistoryItemGroupObs() { return this._currentHistoryItemGroupObs; }
|
||||
readonly currentHistoryItemGroupIdObs = derived<string | undefined>(this, reader => this.currentHistoryItemGroup?.id);
|
||||
readonly currentHistoryItemGroupNameObs = derived<string | undefined>(this, reader => this.currentHistoryItemGroup?.name);
|
||||
|
||||
/**
|
||||
* Changes when the id/name/revision changes for the current, remote, or base history item group
|
||||
*/
|
||||
private readonly _currentHistoryItemGroupWithRevisionObs = observableValueOpts<ISCMHistoryItemGroupWithRevision | undefined>({ owner: this, equalsFn: structuralEquals }, undefined);
|
||||
get currentHistoryItemGroupWithRevisionObs() { return this._currentHistoryItemGroupWithRevisionObs; }
|
||||
private readonly _currentHistoryItemGroupObs = observableValueOpts<ISCMHistoryItemGroup | undefined>({ owner: this, equalsFn: structuralEquals }, undefined);
|
||||
get currentHistoryItemGroupObs() { return this._currentHistoryItemGroupObs; }
|
||||
|
||||
constructor(private readonly proxy: ExtHostSCMShape, private readonly handle: number) { }
|
||||
|
||||
|
@ -227,8 +213,8 @@ class MainThreadSCMHistoryProvider implements ISCMHistoryProvider {
|
|||
}));
|
||||
}
|
||||
|
||||
$onDidChangeCurrentHistoryItemGroup(historyItemGroup: ISCMHistoryItemGroupWithRevision | undefined): void {
|
||||
this._currentHistoryItemGroupWithRevisionObs.set(historyItemGroup, undefined);
|
||||
$onDidChangeCurrentHistoryItemGroup(historyItemGroup: ISCMHistoryItemGroup | undefined): void {
|
||||
this._currentHistoryItemGroupObs.set(historyItemGroup, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1516,7 +1516,7 @@ export type SCMRawResourceSplices = [
|
|||
export interface SCMHistoryItemGroupDto {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly revision: string;
|
||||
readonly revision?: string;
|
||||
readonly base?: Omit<Omit<SCMHistoryItemGroupDto, 'base'>, 'remote'>;
|
||||
readonly remote?: Omit<Omit<SCMHistoryItemGroupDto, 'base'>, 'remote'>;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import { autorun, autorunWithStore, derived, IObservable, observableFromEvent }
|
|||
import { observableConfigValue } from 'vs/platform/observable/common/platformObservableUtils';
|
||||
import { derivedObservableWithCache, latestChangedValue, observableFromEventOpts } from 'vs/base/common/observableInternal/utils';
|
||||
import { Command } from 'vs/editor/common/languages';
|
||||
import { ISCMHistoryItemGroup } from 'vs/workbench/contrib/scm/common/history';
|
||||
|
||||
const ActiveRepositoryContextKeys = {
|
||||
ActiveRepositoryName: new RawContextKey<string>('scmActiveRepositoryName', ''),
|
||||
|
@ -135,9 +134,10 @@ export class SCMActiveRepositoryController extends Disposable implements IWorkbe
|
|||
|
||||
this._register(autorun(reader => {
|
||||
const repository = this._activeRepository.read(reader);
|
||||
const currentHistoryItemGroup = repository?.provider.historyProviderObs.read(reader)?.currentHistoryItemGroupObs.read(reader);
|
||||
const historyProvider = repository?.provider.historyProviderObs.read(reader);
|
||||
const branchName = historyProvider?.currentHistoryItemGroupNameObs.read(reader);
|
||||
|
||||
this._updateActiveRepositoryContextKeys(repository, currentHistoryItemGroup);
|
||||
this._updateActiveRepositoryContextKeys(repository?.provider.name, branchName);
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -196,9 +196,9 @@ export class SCMActiveRepositoryController extends Disposable implements IWorkbe
|
|||
}
|
||||
}
|
||||
|
||||
private _updateActiveRepositoryContextKeys(repository: ISCMRepository | undefined, currentHistoryItemGroup: ISCMHistoryItemGroup | undefined): void {
|
||||
this._activeRepositoryNameContextKey.set(repository?.provider.name ?? '');
|
||||
this._activeRepositoryBranchNameContextKey.set(currentHistoryItemGroup?.name ?? '');
|
||||
private _updateActiveRepositoryContextKeys(repositoryName: string | undefined, branchName: string | undefined): void {
|
||||
this._activeRepositoryNameContextKey.set(repositoryName ?? '');
|
||||
this._activeRepositoryBranchNameContextKey.set(branchName ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ export class SCMWorkingSetController extends Disposable implements IWorkbenchCon
|
|||
|
||||
disposables.add(autorun(async reader => {
|
||||
const historyProvider = repository.provider.historyProviderObs.read(reader);
|
||||
const currentHistoryItemGroupId = historyProvider?.currentHistoryItemGroupObs.read(reader)?.id;
|
||||
const currentHistoryItemGroupId = historyProvider?.currentHistoryItemGroupIdObs.read(reader);
|
||||
|
||||
if (!currentHistoryItemGroupId) {
|
||||
return;
|
||||
|
|
|
@ -21,10 +21,12 @@ export interface ISCMHistoryProvider {
|
|||
|
||||
readonly onDidChangeCurrentHistoryItemGroup: Event<void>;
|
||||
|
||||
get currentHistoryItemGroup(): ISCMHistoryItemGroupWithRevision | undefined;
|
||||
set currentHistoryItemGroup(historyItemGroup: ISCMHistoryItemGroupWithRevision | undefined);
|
||||
get currentHistoryItemGroup(): ISCMHistoryItemGroup | undefined;
|
||||
set currentHistoryItemGroup(historyItemGroup: ISCMHistoryItemGroup | undefined);
|
||||
|
||||
readonly currentHistoryItemGroupIdObs: IObservable<string | undefined>;
|
||||
readonly currentHistoryItemGroupNameObs: IObservable<string | undefined>;
|
||||
readonly currentHistoryItemGroupObs: IObservable<ISCMHistoryItemGroup | undefined>;
|
||||
readonly currentHistoryItemGroupWithRevisionObs: IObservable<ISCMHistoryItemGroupWithRevision | undefined>;
|
||||
|
||||
provideHistoryItems(historyItemGroupId: string, options: ISCMHistoryOptions): Promise<ISCMHistoryItem[] | undefined>;
|
||||
provideHistoryItems2(options: ISCMHistoryOptions): Promise<ISCMHistoryItem[] | undefined>;
|
||||
|
@ -51,18 +53,11 @@ export interface ISCMHistoryOptions {
|
|||
export interface ISCMHistoryItemGroup {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly revision?: string;
|
||||
readonly base?: Omit<Omit<ISCMHistoryItemGroup, 'base'>, 'remote'>;
|
||||
readonly remote?: Omit<Omit<ISCMHistoryItemGroup, 'base'>, 'remote'>;
|
||||
}
|
||||
|
||||
export interface ISCMHistoryItemGroupWithRevision {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly revision: string;
|
||||
readonly base?: Omit<Omit<ISCMHistoryItemGroupWithRevision, 'base'>, 'remote'>;
|
||||
readonly remote?: Omit<Omit<ISCMHistoryItemGroupWithRevision, 'base'>, 'remote'>;
|
||||
}
|
||||
|
||||
export interface SCMHistoryItemGroupTreeElement {
|
||||
readonly id: string;
|
||||
readonly label: string;
|
||||
|
|
|
@ -42,7 +42,7 @@ declare module 'vscode' {
|
|||
export interface SourceControlHistoryItemGroup {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly revision: string;
|
||||
readonly revision?: string;
|
||||
readonly base?: Omit<Omit<SourceControlHistoryItemGroup, 'base'>, 'remote'>;
|
||||
readonly remote?: Omit<Omit<SourceControlHistoryItemGroup, 'base'>, 'remote'>;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue