Kaynağa Gözat

Fixes #2298 ensures repo subscriptions on re-open

main
Eric Amodio 2 yıl önce
ebeveyn
işleme
b5c7e28789
2 değiştirilmiş dosya ile 49 ekleme ve 32 silme
  1. +1
    -0
      CHANGELOG.md
  2. +48
    -32
      src/plus/webviews/graph/graphWebview.ts

+ 1
- 0
CHANGELOG.md Dosyayı Görüntüle

@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#2298](https://github.com/gitkraken/vscode-gitlens/issues/2298) - Commit Graph does not update to current branch correctly
- Fixes [#1549](https://github.com/gitkraken/vscode-gitlens/issues/1549) - Fetch does not work when local branch name differs from remote branch name
- Fixes [#2292](https://github.com/gitkraken/vscode-gitlens/issues/2292) - Push button in BranchTrackingStatusNode of non-current branch does not trigger "Push force"
- Fixes [#1488](https://github.com/gitkraken/vscode-gitlens/issues/1488) - Open Folder History not working with non-English language pack

+ 48
- 32
src/plus/webviews/graph/graphWebview.ts Dosyayı Görüntüle

@ -164,25 +164,14 @@ export class GraphWebview extends WebviewBase {
}
set repository(value: Repository | undefined) {
if (this._repository === value) return;
if (this._repository === value) {
this.ensureRepositorySubscriptions();
return;
}
this._repositoryEventsDisposable?.dispose();
this._repository = value;
this.resetRepositoryState();
if (value != null) {
this._repositoryEventsDisposable = Disposable.from(
value.onDidChange(this.onRepositoryChanged, this),
value.startWatchingFileSystem(),
value.onDidChangeFileSystem(this.onRepositoryFileSystemChanged, this),
onDidChangeContext(key => {
if (key !== ContextKeys.HasConnectedRemotes) return;
this.resetRefsMetadata();
this.updateRefsMetadata();
}),
);
}
this.ensureRepositorySubscriptions(true);
if (this.isReady) {
this.updateState();
@ -282,10 +271,7 @@ export class GraphWebview extends WebviewBase {
const context = Array.isArray(contexts) ? contexts[0] : contexts;
if (context.type === 'scm' && context.scm.rootUri != null) {
const repository = this.container.git.getRepository(context.scm.rootUri);
if (repository != null) {
this.repository = repository;
}
this.repository = this.container.git.getRepository(context.scm.rootUri);
} else if (context.type === 'viewItem' && context.node instanceof RepositoryFolderNode) {
this.repository = context.node.repo;
}
@ -381,11 +367,19 @@ export class GraphWebview extends WebviewBase {
protected override onInitializing(): Disposable[] | undefined {
this._theme = window.activeColorTheme;
this.ensureRepositorySubscriptions();
return [
this.container.subscription.onDidChange(this.onSubscriptionChanged, this),
this.container.git.onDidChangeRepositories(() => void this.refresh(true)),
window.onDidChangeActiveColorTheme(this.onThemeChanged, this),
{ dispose: () => void this._repositoryEventsDisposable?.dispose() },
{
dispose: () => {
if (this._repositoryEventsDisposable == null) return;
this._repositoryEventsDisposable.dispose();
this._repositoryEventsDisposable = undefined;
},
},
];
}
@ -497,6 +491,7 @@ export class GraphWebview extends WebviewBase {
}
}
@debug<GraphWebview['onRepositoryChanged']>({ args: { 0: e => e.toString() } })
private onRepositoryChanged(e: RepositoryChangeEvent) {
if (
!e.changed(
@ -519,11 +514,13 @@ export class GraphWebview extends WebviewBase {
this.updateState();
}
@debug({ args: false })
private onRepositoryFileSystemChanged(e: RepositoryFileSystemChangeEvent) {
if (e.repository?.path !== this.repository?.path) return;
void this.notifyDidChangeWorkingTree();
}
@debug({ args: false })
private onSubscriptionChanged(e: SubscriptionChangeEvent) {
if (e.etag === this._etagSubscription) return;
@ -701,7 +698,7 @@ export class GraphWebview extends WebviewBase {
@debug()
private async onGetMoreRows(e: GetMoreRowsParams, sendSelectedRows: boolean = false) {
if (this._graph?.paging == null) return;
if (this._graph?.more == null || this._repository?.etag !== this._etagRepository) {
if (this._graph?.more == null || this.repository?.etag !== this._etagRepository) {
this.updateState(true);
return;
@ -751,9 +748,9 @@ export class GraphWebview extends WebviewBase {
}
if (search == null || search.comparisonKey !== getSearchQueryComparisonKey(e.search)) {
if (this._repository == null) return;
if (this.repository == null) return;
if (this._repository.etag !== this._etagRepository) {
if (this.repository.etag !== this._etagRepository) {
this.updateState(true);
}
@ -766,7 +763,7 @@ export class GraphWebview extends WebviewBase {
this._searchCancellation = cancellation;
try {
search = await this._repository.searchCommits(e.search, {
search = await this.repository.searchCommits(e.search, {
limit: configuration.get('graph.searchItemLimit') ?? 100,
ordering: configuration.get('graph.commitOrdering'),
cancellation: cancellation.token,
@ -1125,6 +1122,30 @@ export class GraphWebview extends WebviewBase {
}
}
private ensureRepositorySubscriptions(force?: boolean) {
if (!force && this._repositoryEventsDisposable != null) return;
if (this._repositoryEventsDisposable != null) {
this._repositoryEventsDisposable.dispose();
this._repositoryEventsDisposable = undefined;
}
const repo = this.repository;
if (repo == null) return;
this._repositoryEventsDisposable = Disposable.from(
repo.onDidChange(this.onRepositoryChanged, this),
repo.startWatchingFileSystem(),
repo.onDidChangeFileSystem(this.onRepositoryFileSystemChanged, this),
onDidChangeContext(key => {
if (key !== ContextKeys.HasConnectedRemotes) return;
this.resetRefsMetadata();
this.updateRefsMetadata();
}),
);
}
private async ensureSearchStartsInRange(graph: GitGraph, search: GitSearch) {
if (search.results.size === 0) return undefined;
@ -1279,12 +1300,7 @@ export class GraphWebview extends WebviewBase {
}
private async getWorkingTreeStats(): Promise<GraphWorkingTreeStats | undefined> {
if (this.container.git.repositoryCount === 0) return undefined;
if (this.repository == null) {
this.repository = this.container.git.getBestRepositoryOrFirst();
if (this.repository == null) return undefined;
}
if (this.repository == null || this.container.git.repositoryCount === 0) return undefined;
const status = await this.container.git.getStatusForRepo(this.repository.path);
const workingTreeStatus = status?.getDiffStatus();
@ -1737,7 +1753,7 @@ export class GraphWebview extends WebviewBase {
return GitActions.switchTo(ref.repoPath);
}
return GitActions.switchTo(this._repository);
return GitActions.switchTo(this.repository);
}
@debug()

Yükleniyor…
İptal
Kaydet