@@ -125,6 +125,13 @@ export class GitExtension implements IGitExtension, IDisposable {
125125 return this . _statusChanged ;
126126 }
127127
128+ /**
129+ * A signal emitted when the current marking of the git repository changes.
130+ */
131+ get markChanged ( ) : ISignal < IGitExtension , void > {
132+ return this . _markChanged ;
133+ }
134+
128135 public get commands ( ) : CommandRegistry | null {
129136 return this . _app ? this . _app . commands : null ;
130137 }
@@ -856,12 +863,13 @@ export class GitExtension implements IGitExtension, IDisposable {
856863 private _app : JupyterFrontEnd | null ;
857864 private _diffProviders : { [ key : string ] : Git . IDiffCallback } = { } ;
858865 private _isDisposed = false ;
859- private _markerCache : Markers = new Markers ( ) ;
866+ private _markerCache : Markers = new Markers ( ( ) => this . _markChanged . emit ( ) ) ;
860867 private _currentMarker : BranchMarker = null ;
861868 private _readyPromise : Promise < void > = Promise . resolve ( ) ;
862869 private _pendingReadyPromise = 0 ;
863870 private _poll : Poll ;
864871 private _headChanged = new Signal < IGitExtension , void > ( this ) ;
872+ private _markChanged = new Signal < IGitExtension , void > ( this ) ;
865873 private _repositoryChanged = new Signal <
866874 IGitExtension ,
867875 IChangedArgs < string | null >
@@ -872,9 +880,11 @@ export class GitExtension implements IGitExtension, IDisposable {
872880}
873881
874882export class BranchMarker {
883+ constructor ( private _refresh : ( ) => void ) { }
884+
875885 add ( fname : string , mark : boolean = true ) {
876886 if ( ! ( fname in this . _marks ) ) {
877- this . _marks [ fname ] = mark ;
887+ this . set ( fname , mark ) ;
878888 }
879889 }
880890
@@ -895,28 +905,35 @@ export class BranchMarker {
895905 }
896906
897907 mark ( fname : string ) {
898- this . _marks [ fname ] = true ;
908+ this . set ( fname , true ) ;
899909 }
900910
901911 unmark ( fname : string ) {
902- this . _marks [ fname ] = false ;
912+ this . set ( fname , false ) ;
913+ }
914+
915+ set ( fname : string , mark : boolean ) {
916+ this . _marks [ fname ] = mark ;
917+ this . _refresh ( ) ;
903918 }
904919
905920 toggle ( fname : string ) {
906- this . _marks [ fname ] = ! this . _marks [ fname ] ;
921+ this . set ( fname , ! this . _marks [ fname ] ) ;
907922 }
908923
909924 private _marks : { [ key : string ] : boolean } = { } ;
910925}
911926
912927export class Markers {
928+ constructor ( private _refresh : ( ) => void ) { }
929+
913930 get ( path : string , branch : string ) : BranchMarker {
914931 const key = Markers . markerKey ( path , branch ) ;
915932 if ( key in this . _branchMarkers ) {
916933 return this . _branchMarkers [ key ] ;
917934 }
918935
919- let marker = new BranchMarker ( ) ;
936+ let marker = new BranchMarker ( this . _refresh ) ;
920937 this . _branchMarkers [ key ] = marker ;
921938 return marker ;
922939 }
0 commit comments