@@ -15,7 +15,7 @@ import { ISettingRegistry } from '@jupyterlab/settingregistry';
15
15
import { ITerminal } from '@jupyterlab/terminal' ;
16
16
import { CommandRegistry } from '@lumino/commands' ;
17
17
import { Menu } from '@lumino/widgets' ;
18
- import { toArray , ArrayExt } from '@lumino/algorithm' ;
18
+ import { ArrayExt , toArray } from '@lumino/algorithm' ;
19
19
import * as React from 'react' ;
20
20
import {
21
21
Diff ,
@@ -710,6 +710,12 @@ export function addCommands(
710
710
} ) ;
711
711
}
712
712
} ) ;
713
+
714
+ commands . addCommand ( ContextCommandIDs . gitNoAction , {
715
+ label : 'No actions available' ,
716
+ isEnabled : ( ) => false ,
717
+ execute : ( ) => void 0
718
+ } ) ;
713
719
}
714
720
715
721
/**
@@ -845,7 +851,9 @@ export function addFileBrowserContextMenu(
845
851
846
852
const items = getSelectedBrowserItems ( ) ;
847
853
const statuses = new Set < Git . Status > (
848
- items . map ( item => model . getFileStatus ( item . path ) )
854
+ items
855
+ . map ( item => model . getFileStatus ( item . path ) )
856
+ . filter ( status => typeof status !== 'undefined' )
849
857
) ;
850
858
851
859
// get commands and de-duplicate them
@@ -858,10 +866,18 @@ export function addFileBrowserContextMenu(
858
866
. filter (
859
867
command =>
860
868
command !== ContextCommandIDs . gitFileOpen &&
861
- command !== ContextCommandIDs . gitFileDelete
869
+ command !== ContextCommandIDs . gitFileDelete &&
870
+ typeof command !== 'undefined'
862
871
)
863
872
) ;
864
873
874
+ // if looking at a tracked file with no changes,
875
+ // it has no status, nor any actions available
876
+ // (although `git rm` would be a valid action)
877
+ if ( allCommands . size === 0 && statuses . size === 0 ) {
878
+ allCommands . add ( ContextCommandIDs . gitNoAction ) ;
879
+ }
880
+
865
881
const commandsChanged =
866
882
! this . _commands ||
867
883
this . _commands . length !== allCommands . size ||
0 commit comments