@@ -144,6 +144,8 @@ class GitBlameInformationCache {
144
144
}
145
145
146
146
export class GitBlameController {
147
+ private readonly _subjectMaxLength = 50 ;
148
+
147
149
private readonly _onDidChangeBlameInformation = new EventEmitter < TextEditor > ( ) ;
148
150
public readonly onDidChangeBlameInformation = this . _onDidChangeBlameInformation . event ;
149
151
@@ -169,10 +171,14 @@ export class GitBlameController {
169
171
}
170
172
171
173
formatBlameInformationMessage ( template : string , blameInformation : BlameInformation ) : string {
174
+ const subject = blameInformation . subject && blameInformation . subject . length > this . _subjectMaxLength
175
+ ? `${ blameInformation . subject . substring ( 0 , this . _subjectMaxLength ) } \u2026`
176
+ : blameInformation . subject ;
177
+
172
178
const templateTokens = {
173
179
hash : blameInformation . hash ,
174
180
hashShort : blameInformation . hash . substring ( 0 , 8 ) ,
175
- subject : emojify ( blameInformation . subject ?? '' ) ,
181
+ subject : emojify ( subject ?? '' ) ,
176
182
authorName : blameInformation . authorName ?? '' ,
177
183
authorEmail : blameInformation . authorEmail ?? '' ,
178
184
authorDate : new Date ( blameInformation . authorDate ?? new Date ( ) ) . toLocaleString ( ) ,
@@ -421,6 +427,8 @@ class GitBlameEditorDecoration {
421
427
this . _disposables . push ( this . _decorationType ) ;
422
428
423
429
workspace . onDidChangeConfiguration ( this . _onDidChangeConfiguration , this , this . _disposables ) ;
430
+ window . onDidChangeActiveTextEditor ( this . _onDidChangeActiveTextEditor , this , this . _disposables ) ;
431
+
424
432
this . _controller . onDidChangeBlameInformation ( e => this . _updateDecorations ( e ) , this , this . _disposables ) ;
425
433
}
426
434
@@ -439,6 +447,18 @@ class GitBlameEditorDecoration {
439
447
}
440
448
}
441
449
450
+ private _onDidChangeActiveTextEditor ( ) : void {
451
+ if ( ! this . _getConfiguration ( ) . enabled ) {
452
+ return ;
453
+ }
454
+
455
+ for ( const editor of window . visibleTextEditors ) {
456
+ if ( editor !== window . activeTextEditor ) {
457
+ editor . setDecorations ( this . _decorationType , [ ] ) ;
458
+ }
459
+ }
460
+ }
461
+
442
462
private _getConfiguration ( ) : { enabled : boolean ; template : string } {
443
463
const config = workspace . getConfiguration ( 'git' ) ;
444
464
const enabled = config . get < boolean > ( 'blame.editorDecoration.enabled' , false ) ;
@@ -453,15 +473,6 @@ class GitBlameEditorDecoration {
453
473
return ;
454
474
}
455
475
456
- // Clear decorations for the other editors
457
- for ( const editor of window . visibleTextEditors ) {
458
- if ( editor === textEditor ) {
459
- continue ;
460
- }
461
-
462
- editor . setDecorations ( this . _decorationType , [ ] ) ;
463
- }
464
-
465
476
// Only support resources with `file` and `git` schemes
466
477
if ( textEditor . document . uri . scheme !== 'file' && ! isGitUri ( textEditor . document . uri ) ) {
467
478
textEditor . setDecorations ( this . _decorationType , [ ] ) ;
@@ -543,9 +554,7 @@ class GitBlameStatusBarItem {
543
554
return ;
544
555
}
545
556
546
- if ( window . activeTextEditor ) {
547
- this . _updateStatusBarItem ( window . activeTextEditor ) ;
548
- } else {
557
+ if ( ! window . activeTextEditor ) {
549
558
this . _statusBarItem ?. hide ( ) ;
550
559
}
551
560
}
0 commit comments