11'use strict' ;
2- import { CodeLens , commands , DocumentSelector , ExtensionContext , languages , Range , Uri , window , workspace } from 'vscode' ;
2+ import { CodeLens , commands , DocumentSelector , ExtensionContext , languages , Position , Range , Uri , window , workspace } from 'vscode' ;
33import GitCodeLensProvider , { GitBlameCodeLens } from './codeLensProvider' ;
44import GitContentProvider from './contentProvider' ;
55import { gitRepoPath } from './git' ;
@@ -24,20 +24,22 @@ export function activate(context: ExtensionContext) {
2424
2525 context . subscriptions . push ( workspace . registerTextDocumentContentProvider ( GitContentProvider . scheme , new GitContentProvider ( context , blameProvider ) ) ) ;
2626
27- context . subscriptions . push ( commands . registerCommand ( Commands . ShowBlameHistory , ( uri : Uri , blameRange ?: Range , range ?: Range ) => {
27+ context . subscriptions . push ( commands . registerCommand ( Commands . ShowBlameHistory , ( uri ?: Uri , range ?: Range , position ?: Position ) => {
28+ // If the command is executed manually -- treat it as a click on the root lens (i.e. show blame for the whole file)
2829 if ( ! uri ) {
2930 const doc = window . activeTextEditor && window . activeTextEditor . document ;
3031 if ( doc ) {
3132 uri = doc . uri ;
32- blameRange = doc . validateRange ( new Range ( 0 , 0 , 1000000 , 1000000 ) ) ;
33- range = doc . validateRange ( new Range ( 0 , 0 , 0 , 1000000 ) ) ;
33+ range = doc . validateRange ( new Range ( 0 , 0 , 1000000 , 1000000 ) ) ;
34+ position = doc . validateRange ( new Range ( 0 , 0 , 0 , 1000000 ) ) . start ;
3435 }
3536
3637 if ( ! uri ) return ;
3738 }
3839
39- return blameProvider . getBlameLocations ( uri . path , blameProvider . repoPath , blameRange ) . then ( locations => {
40- return commands . executeCommand ( VsCodeCommands . ShowReferences , uri , range , locations ) ;
40+ console . log ( uri . path , blameProvider . repoPath , range , position ) ;
41+ return blameProvider . getBlameLocations ( uri . path , blameProvider . repoPath , range ) . then ( locations => {
42+ return commands . executeCommand ( VsCodeCommands . ShowReferences , uri , position , locations ) ;
4143 } ) ;
4244 } ) ) ;
4345
0 commit comments