From d78a74bcdfad14d5d3b1b782f87255d802b57511 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:59:59 +0200 Subject: [PATCH] SCM - fix graph refresh while switching between editor tabs (#230292) --- .../workbench/contrib/scm/browser/scmViewService.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/scm/browser/scmViewService.ts b/src/vs/workbench/contrib/scm/browser/scmViewService.ts index 38c0119b7deff..eea8d5d1fb311 100644 --- a/src/vs/workbench/contrib/scm/browser/scmViewService.ts +++ b/src/vs/workbench/contrib/scm/browser/scmViewService.ts @@ -18,7 +18,7 @@ import { binarySearch } from '../../../../base/common/arrays.js'; import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js'; import { IContextKey, IContextKeyService, RawContextKey } from '../../../../platform/contextkey/common/contextkey.js'; import { IExtensionService } from '../../../services/extensions/common/extensions.js'; -import { derivedObservableWithCache, latestChangedValue, observableFromEventOpts } from '../../../../base/common/observable.js'; +import { derivedObservableWithCache, derivedOpts, latestChangedValue, observableFromEventOpts } from '../../../../base/common/observable.js'; import { IEditorService } from '../../../services/editor/common/editorService.js'; import { EditorResourceAccessor } from '../../../common/editor.js'; @@ -186,7 +186,15 @@ export class SCMViewService implements ISCMViewService { * The focused repository takes precedence over the active editor repository when the observable * values are updated in the same transaction (or during the initial read of the observable value). */ - readonly activeRepository = latestChangedValue(this, [this._activeEditorRepository, this._focusedRepository]); + private readonly _activeRepository = latestChangedValue(this, [this._activeEditorRepository, this._focusedRepository]); + + /** + * Derived with a custom equality function + */ + readonly activeRepository = derivedOpts({ + owner: this, + equalsFn: (r1, r2) => r1?.id === r2?.id + }, reader => this._activeRepository.read(reader)); private _repositoriesSortKey: ISCMRepositorySortKey; private _sortKeyContextKey: IContextKey;