22import { Strings } from '../system' ;
33import { DecorationOptions , Range } from 'vscode' ;
44import { FileAnnotationType } from './annotationController' ;
5- import { Annotations , endOfLineIndex } from './annotations' ;
5+ import { Annotations } from './annotations' ;
66import { BlameAnnotationProviderBase } from './blameAnnotationProvider' ;
77import { GlyphChars } from '../constants' ;
88import { GitBlameCommit , ICommitFormatOptions } from '../gitService' ;
@@ -35,18 +35,14 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
3535 const now = Date . now ( ) ;
3636 const offset = this . uri . offset ;
3737 const renderOptions = Annotations . gutterRenderOptions ( this . _config . theme , cfg . heatmap ) ;
38- const dateFormat = this . _config . defaultDateFormat ;
3938 const separateLines = this . _config . theme . annotations . file . gutter . separateLines ;
4039
4140 const decorations : DecorationOptions [ ] = [ ] ;
42- const decorationsMap : { [ sha : string ] : DecorationOptions } = Object . create ( null ) ;
43- const document = this . document ;
41+ const decorationsMap : { [ sha : string ] : DecorationOptions | undefined } = Object . create ( null ) ;
4442
4543 let commit : GitBlameCommit | undefined ;
4644 let compacted = false ;
47- let details : DecorationOptions | undefined ;
4845 let gutter : DecorationOptions | undefined ;
49- let hasRemotes : boolean | undefined ;
5046 let previousSha : string | undefined ;
5147
5248 for ( const l of blame . lines ) {
@@ -55,63 +51,50 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
5551 if ( previousSha === l . sha ) {
5652 // Use a shallow copy of the previous decoration options
5753 gutter = { ...gutter } as DecorationOptions ;
54+
5855 if ( cfg . compact && ! compacted ) {
5956 // Since we are wiping out the contextText make sure to copy the objects
60- gutter . renderOptions = { ...gutter . renderOptions } ;
61- gutter . renderOptions . before = {
62- ...gutter . renderOptions . before ,
63- ...{ contentText : GlyphChars . Space . repeat ( Strings . getWidth ( gutter . renderOptions ! . before ! . contentText ! ) ) }
57+ gutter . renderOptions = {
58+ ...gutter . renderOptions ,
59+ before : {
60+ ...gutter . renderOptions ! . before ,
61+ contentText : GlyphChars . Space . repeat ( Strings . getWidth ( gutter . renderOptions ! . before ! . contentText ! ) )
62+ }
6463 } ;
6564
6665 if ( separateLines ) {
67- gutter . renderOptions . dark = { ...gutter . renderOptions . dark } ;
68- gutter . renderOptions . dark . before = { ...gutter . renderOptions . dark . before , ...{ textDecoration : 'none' } } ;
69- gutter . renderOptions . light = { ...gutter . renderOptions . light } ;
70- gutter . renderOptions . light . before = { ...gutter . renderOptions . light . before , ...{ textDecoration : 'none' } } ;
66+ gutter . renderOptions . dark = {
67+ ...gutter . renderOptions . dark ,
68+ before : { ...gutter . renderOptions . dark ! . before , textDecoration : 'none' }
69+ } ;
70+ gutter . renderOptions . light = {
71+ ...gutter . renderOptions . light ,
72+ before : { ...gutter . renderOptions . light ! . before , textDecoration : 'none' }
73+ } ;
7174 }
7275
7376 compacted = true ;
7477 }
7578
76- const endIndex = document . lineAt ( line ) . firstNonWhitespaceCharacterIndex ;
77- gutter . range = new Range ( line , 0 , line , endIndex ) ;
79+ gutter . range = new Range ( line , 0 , line , 0 ) ;
7880
7981 decorations . push ( gutter ) ;
8082
81- if ( details !== undefined ) {
82- details = { ...details } as DecorationOptions ;
83- details . range = cfg . hover . wholeLine
84- ? document . validateRange ( new Range ( line , 0 , line , endOfLineIndex ) )
85- : gutter . range ;
86-
87- decorations . push ( details ) ;
88- }
89-
9083 continue ;
9184 }
9285
9386 compacted = false ;
9487 previousSha = l . sha ;
9588
9689 gutter = decorationsMap [ l . sha ] ;
97-
9890 if ( gutter !== undefined ) {
99- gutter = { ... gutter } as DecorationOptions ;
100-
101- const endIndex = document . lineAt ( line ) . firstNonWhitespaceCharacterIndex ;
102- gutter . range = new Range ( line , 0 , line , endIndex ) ;
91+ gutter = {
92+ ... gutter ,
93+ range : new Range ( line , 0 , line , 0 )
94+ } as DecorationOptions ;
10395
10496 decorations . push ( gutter ) ;
10597
106- if ( details !== undefined ) {
107- details = { ...details } as DecorationOptions ;
108- details . range = cfg . hover . wholeLine
109- ? document . validateRange ( new Range ( line , 0 , line , endOfLineIndex ) )
110- : gutter . range ;
111-
112- decorations . push ( details ) ;
113- }
114-
11598 continue ;
11699 }
117100
@@ -124,24 +107,10 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
124107 Annotations . applyHeatmap ( gutter , commit . date , now ) ;
125108 }
126109
127- const endIndex = document . lineAt ( line ) . firstNonWhitespaceCharacterIndex ;
128- gutter . range = new Range ( line , 0 , line , endIndex ) ;
110+ gutter . range = new Range ( line , 0 , line , 0 ) ;
129111
130112 decorations . push ( gutter ) ;
131113 decorationsMap [ l . sha ] = gutter ;
132-
133- if ( cfg . hover . details ) {
134- if ( hasRemotes === undefined ) {
135- hasRemotes = this . git . hasRemotes ( commit . repoPath ) ;
136- }
137-
138- details = Annotations . detailsHover ( commit , dateFormat , hasRemotes ) ;
139- details . range = cfg . hover . wholeLine
140- ? document . validateRange ( new Range ( line , 0 , line , endOfLineIndex ) )
141- : gutter . range ;
142-
143- decorations . push ( details ) ;
144- }
145114 }
146115
147116 if ( decorations . length ) {
@@ -151,6 +120,10 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
151120 const duration = process . hrtime ( start ) ;
152121 Logger . log ( `${ ( duration [ 0 ] * 1000 ) + Math . floor ( duration [ 1 ] / 1000000 ) } ms to compute gutter blame annotations` ) ;
153122
123+ if ( cfg . hover . details ) {
124+ this . registerHoverProvider ( ) ;
125+ }
126+
154127 this . selection ( shaOrLine , blame ) ;
155128 return true ;
156129 }
0 commit comments