@@ -15,7 +15,7 @@ import { ISettingRegistry } from '@jupyterlab/settingregistry';
1515import { ITerminal } from '@jupyterlab/terminal' ;
1616import { CommandRegistry } from '@lumino/commands' ;
1717import { Menu } from '@lumino/widgets' ;
18- import { toArray , ArrayExt } from '@lumino/algorithm' ;
18+ import { ArrayExt , toArray } from '@lumino/algorithm' ;
1919import * as React from 'react' ;
2020import {
2121 Diff ,
@@ -710,6 +710,12 @@ export function addCommands(
710710 } ) ;
711711 }
712712 } ) ;
713+
714+ commands . addCommand ( ContextCommandIDs . gitNoAction , {
715+ label : 'No actions available' ,
716+ isEnabled : ( ) => false ,
717+ execute : ( ) => void 0
718+ } ) ;
713719}
714720
715721/**
@@ -845,7 +851,9 @@ export function addFileBrowserContextMenu(
845851
846852 const items = getSelectedBrowserItems ( ) ;
847853 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' )
849857 ) ;
850858
851859 // get commands and de-duplicate them
@@ -858,10 +866,18 @@ export function addFileBrowserContextMenu(
858866 . filter (
859867 command =>
860868 command !== ContextCommandIDs . gitFileOpen &&
861- command !== ContextCommandIDs . gitFileDelete
869+ command !== ContextCommandIDs . gitFileDelete &&
870+ typeof command !== 'undefined'
862871 )
863872 ) ;
864873
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+
865881 const commandsChanged =
866882 ! this . _commands ||
867883 this . _commands . length !== allCommands . size ||
0 commit comments