@@ -20,6 +20,7 @@ export class SignsFeature {
2020 private signsProvider ?: SignsProvider ;
2121 private workspaceLeafChangeEvent ?: EventRef ;
2222 private fileRenameEvent ?: EventRef ;
23+ private intervalRefreshEvent ?: number ;
2324 private pluginRefreshedEvent ?: EventRef ;
2425 private gutterContextMenuEvent ?: EventRef ;
2526 private codeMirrorExtensions : Extension [ ] = [ ] ;
@@ -133,16 +134,20 @@ export class SignsFeature {
133134 this . fileRenameEvent = this . createFileRenameEvent ( ) ;
134135 this . pluginRefreshedEvent = this . createPluginRefreshedEvent ( ) ;
135136
137+ this . intervalRefreshEvent = this . createIntervalRefreshEvent ( ) ;
138+
136139 this . plg . registerEvent ( this . workspaceLeafChangeEvent ) ;
137140 this . plg . registerEvent ( this . fileRenameEvent ) ;
138141 this . plg . registerEvent ( this . pluginRefreshedEvent ) ;
142+ this . plg . registerInterval ( this . intervalRefreshEvent ) ;
139143 }
140144
141145 private destroyEventHandlers ( ) {
142146 this . plg . app . workspace . offref ( this . workspaceLeafChangeEvent ! ) ;
143147 this . plg . app . vault . offref ( this . fileRenameEvent ! ) ;
144148 this . plg . app . workspace . offref ( this . pluginRefreshedEvent ! ) ;
145149 this . plg . app . workspace . offref ( this . gutterContextMenuEvent ! ) ;
150+ window . clearInterval ( this . intervalRefreshEvent ) ;
146151 }
147152
148153 private handleWorkspaceLeaf = ( leaf : WorkspaceLeaf ) => {
@@ -189,11 +194,23 @@ export class SignsFeature {
189194 }
190195
191196 private createPluginRefreshedEvent ( ) : EventRef {
192- return this . plg . app . workspace . on ( "obsidian-git:refreshed " , ( ) => {
197+ return this . plg . app . workspace . on ( "obsidian-git:refresh " , ( ) => {
193198 this . refresh ( ) ;
194199 } ) ;
195200 }
196201
202+ private createIntervalRefreshEvent ( ) : number {
203+ // Refresh every 10 seconds the active editor to account for external
204+ // git index changes
205+ return window . setInterval ( ( ) => {
206+ if ( this . plg . app . workspace . activeEditor ?. file ) {
207+ this . signsProvider
208+ ?. trackChanged ( this . plg . app . workspace . activeEditor . file )
209+ . catch ( console . error ) ;
210+ }
211+ } , 10 * 1000 ) ;
212+ }
213+
197214 //TODO do we need this?
198215 private createHeadChangeEvent ( ) : EventRef {
199216 return this . plg . app . workspace . on ( "obsidian-git:head-change" , ( ) => {
0 commit comments