@@ -61,7 +61,6 @@ import { compare } from '../../../../base/common/strings.js';
61
61
import { IClipboardService } from '../../../../platform/clipboard/common/clipboardService.js' ;
62
62
import { getDefaultHoverDelegate } from '../../../../base/browser/ui/hover/hoverDelegateFactory.js' ;
63
63
import { IStorageService , StorageScope , StorageTarget } from '../../../../platform/storage/common/storage.js' ;
64
- import { INotificationService } from '../../../../platform/notification/common/notification.js' ;
65
64
import { IExtensionService } from '../../../services/extensions/common/extensions.js' ;
66
65
import { groupBy as groupBy2 } from '../../../../base/common/collections.js' ;
67
66
@@ -196,7 +195,9 @@ registerAction2(class extends ViewAction<SCMHistoryViewPane> {
196
195
title : localize ( 'goToCurrentHistoryItem' , "Go to Current History Item" ) ,
197
196
icon : Codicon . target ,
198
197
viewId : HISTORY_VIEW_PANE_ID ,
199
- precondition : ContextKeys . SCMHistoryItemCount . notEqualsTo ( 0 ) ,
198
+ precondition : ContextKeyExpr . and (
199
+ ContextKeys . SCMHistoryItemCount . notEqualsTo ( 0 ) ,
200
+ ContextKeys . SCMCurrentHistoryItemRefInFilter . isEqualTo ( true ) ) ,
200
201
f1 : false ,
201
202
menu : {
202
203
id : MenuId . SCMHistoryTitle ,
@@ -1205,12 +1206,13 @@ export class SCMHistoryViewPane extends ViewPane {
1205
1206
private readonly _updateChildrenThrottler = new Throttler ( ) ;
1206
1207
1207
1208
private readonly _scmProviderCtx : IContextKey < string | undefined > ;
1209
+ private readonly _scmCurrentHistoryItemRefHasRemote : IContextKey < boolean > ;
1210
+ private readonly _scmCurrentHistoryItemRefInFilter : IContextKey < boolean > ;
1208
1211
1209
1212
constructor (
1210
1213
options : IViewPaneOptions ,
1211
1214
@ICommandService private readonly _commandService : ICommandService ,
1212
1215
@IInstantiationService private readonly _instantiationService : IInstantiationService ,
1213
- @INotificationService private readonly _notificationService : INotificationService ,
1214
1216
@IProgressService private readonly _progressService : IProgressService ,
1215
1217
@IConfigurationService configurationService : IConfigurationService ,
1216
1218
@IContextMenuService contextMenuService : IContextMenuService ,
@@ -1230,6 +1232,8 @@ export class SCMHistoryViewPane extends ViewPane {
1230
1232
} , keybindingService , contextMenuService , configurationService , contextKeyService , viewDescriptorService , instantiationService , openerService , themeService , telemetryService , hoverService ) ;
1231
1233
1232
1234
this . _scmProviderCtx = ContextKeys . SCMProvider . bindTo ( this . scopedContextKeyService ) ;
1235
+ this . _scmCurrentHistoryItemRefHasRemote = ContextKeys . SCMCurrentHistoryItemRefHasRemote . bindTo ( this . scopedContextKeyService ) ;
1236
+ this . _scmCurrentHistoryItemRefInFilter = ContextKeys . SCMCurrentHistoryItemRefInFilter . bindTo ( this . scopedContextKeyService ) ;
1233
1237
1234
1238
this . _actionRunner = this . instantiationService . createInstance ( SCMHistoryViewPaneActionRunner ) ;
1235
1239
this . _register ( this . _actionRunner ) ;
@@ -1311,15 +1315,15 @@ export class SCMHistoryViewPane extends ViewPane {
1311
1315
return ;
1312
1316
}
1313
1317
1314
- // Update context
1315
- this . _scmProviderCtx . set ( repository . provider . contextValue ) ;
1316
-
1317
1318
// HistoryItemId changed (checkout)
1318
1319
const historyItemRefId = derived ( reader => {
1319
1320
return historyProvider . historyItemRef . read ( reader ) ?. id ;
1320
1321
} ) ;
1321
- store . add ( runOnChange ( historyItemRefId , ( ) => {
1322
+ store . add ( runOnChange ( historyItemRefId , historyItemRefIdValue => {
1322
1323
this . refresh ( ) ;
1324
+
1325
+ // Update context key (needs to be done after the refresh call)
1326
+ this . _scmCurrentHistoryItemRefInFilter . set ( this . _isCurrentHistoryItemInFilter ( historyItemRefIdValue ) ) ;
1323
1327
} ) ) ;
1324
1328
1325
1329
// HistoryItemRefs changed
@@ -1344,8 +1348,20 @@ export class SCMHistoryViewPane extends ViewPane {
1344
1348
// HistoryItemRefs filter changed
1345
1349
store . add ( runOnChange ( this . _treeViewModel . onDidChangeHistoryItemsFilter , ( ) => {
1346
1350
this . refresh ( ) ;
1351
+
1352
+ // Update context key (needs to be done after the refresh call)
1353
+ this . _scmCurrentHistoryItemRefInFilter . set ( this . _isCurrentHistoryItemInFilter ( historyItemRefId . get ( ) ) ) ;
1347
1354
} ) ) ;
1348
1355
1356
+ // HistoryItemRemoteRef changed
1357
+ store . add ( autorun ( reader => {
1358
+ this . _scmCurrentHistoryItemRefHasRemote . set ( ! ! historyProvider . historyItemRemoteRef . read ( reader ) ) ;
1359
+ } ) ) ;
1360
+
1361
+ // Update context
1362
+ this . _scmProviderCtx . set ( repository . provider . contextValue ) ;
1363
+ this . _scmCurrentHistoryItemRefInFilter . set ( this . _isCurrentHistoryItemInFilter ( historyItemRefId . get ( ) ) ) ;
1364
+
1349
1365
// We skip refreshing the graph on the first execution of the autorun
1350
1366
// since the graph for the first repository is rendered when the tree
1351
1367
// input is set.
@@ -1438,16 +1454,11 @@ export class SCMHistoryViewPane extends ViewPane {
1438
1454
const repository = this . _treeViewModel . repository . get ( ) ;
1439
1455
const historyProvider = repository ?. provider . historyProvider . get ( ) ;
1440
1456
const historyItemRef = historyProvider ?. historyItemRef . get ( ) ;
1441
- const historyItemFilter = this . _treeViewModel . getHistoryItemsFilter ( ) ;
1442
-
1443
- if ( ! repository || ! historyItemRef ?. revision || ! historyItemFilter ) {
1457
+ if ( ! repository || ! historyItemRef ?. id || ! historyItemRef ?. revision ) {
1444
1458
return ;
1445
1459
}
1446
1460
1447
- // Filter set to `all`, `auto` or it contains the current history item
1448
- if ( Array . isArray ( historyItemFilter ) &&
1449
- ! historyItemFilter . find ( ref => ref . id === historyItemRef . id ) ) {
1450
- this . _notificationService . info ( localize ( 'scmGraphViewRevealCurrentHistoryItem' , "The current history item is not present in the source control graph. Please use the history item references picker to expand the set of history items in the graph." ) ) ;
1461
+ if ( this . _isCurrentHistoryItemInFilter ( historyItemRef . id ) ) {
1451
1462
return ;
1452
1463
}
1453
1464
@@ -1513,6 +1524,19 @@ export class SCMHistoryViewPane extends ViewPane {
1513
1524
this . _tree . onContextMenu ( this . _onContextMenu , this , this . _store ) ;
1514
1525
}
1515
1526
1527
+ private _isCurrentHistoryItemInFilter ( historyItemRefId : string | undefined ) : boolean {
1528
+ if ( ! historyItemRefId ) {
1529
+ return false ;
1530
+ }
1531
+
1532
+ const historyItemFilter = this . _treeViewModel . getHistoryItemsFilter ( ) ;
1533
+ if ( historyItemFilter === 'all' || historyItemFilter === 'auto' ) {
1534
+ return true ;
1535
+ }
1536
+
1537
+ return Array . isArray ( historyItemFilter ) && ! ! historyItemFilter . find ( ref => ref . id === historyItemRefId ) ;
1538
+ }
1539
+
1516
1540
private async _onDidOpen ( e : IOpenEvent < TreeElement | undefined > ) : Promise < void > {
1517
1541
if ( ! e . element ) {
1518
1542
return ;
0 commit comments