@@ -11,6 +11,9 @@ export class ChangesStatusBar {
1111 if ( plugin . settings . hunks . statusBar === "colored" ) {
1212 statusBarEl . addClass ( "git-changes-status-bar-colored" ) ;
1313 }
14+
15+ statusBarEl . setAttr ( "aria-label" , "Git diff of the current editor" ) ;
16+ this . statusBarEl . setAttribute ( "data-tooltip-position" , "top" ) ;
1417 plugin . app . workspace . on ( "active-leaf-change" , ( leaf ) => {
1518 if (
1619 ! leaf ||
@@ -23,41 +26,39 @@ export class ChangesStatusBar {
2326 }
2427
2528 display ( hunks : Hunk [ ] , file : TFile | null ) : void {
26- if ( this . plugin . gitReady ) {
27- const mdView =
28- this . plugin . app . workspace . getActiveViewOfType ( MarkdownView ) ;
29- if ( ! mdView || mdView . file ?. path !== file ?. path ) {
30- return ;
31- }
29+ const mdView =
30+ this . plugin . app . workspace . getActiveViewOfType ( MarkdownView ) ;
31+ if ( ! mdView || mdView . file ?. path !== file ?. path ) {
32+ return ;
33+ }
3234
33- let added : number = 0 ,
34- changed : number = 0 ,
35- deleted : number = 0 ;
36- for ( const hunk of hunks ) {
37- added += Math . max ( 0 , hunk . added . count - hunk . removed . count ) ;
38- changed += Math . min ( hunk . added . count , hunk . removed . count ) ;
39- deleted += Math . max ( 0 , hunk . removed . count - hunk . added . count ) ;
40- }
41- // this.statusBarEl.setText(`+${added} ~${changed} -${deleted}` );
42- this . statusBarEl . empty ( ) ;
35+ let added : number = 0 ,
36+ changed : number = 0 ,
37+ deleted : number = 0 ;
38+ for ( const hunk of hunks ) {
39+ added += Math . max ( 0 , hunk . added . count - hunk . removed . count ) ;
40+ changed += Math . min ( hunk . added . count , hunk . removed . count ) ;
41+ deleted += Math . max ( 0 , hunk . removed . count - hunk . added . count ) ;
42+ }
43+ this . statusBarEl . empty ( ) ;
44+ if ( added > 0 ) {
4345 this . statusBarEl . createSpan ( {
4446 text : `+${ added } ` ,
4547 cls : "git-add" ,
4648 } ) ;
49+ }
50+ if ( changed > 0 ) {
4751 this . statusBarEl . createSpan ( {
4852 text : `~${ changed } ` ,
4953 cls : "git-change" ,
5054 } ) ;
55+ }
56+ if ( deleted > 0 ) {
5157 this . statusBarEl . createSpan ( {
5258 text : `-${ deleted } ` ,
5359 cls : "git-delete" ,
5460 } ) ;
55- } else {
56- this . statusBarEl . empty ( ) ;
5761 }
58- // } else {
59- // this.statusBarEl.empty();
60- // }
6162 }
6263
6364 remove ( ) {
0 commit comments