@@ -127,16 +127,24 @@ export const getAllBlameDecorations = (
127127) => hunks . map ( hunk => getDecorationFromHunk ( hunk , now , hunk . startLine - 1 , settings , sourcegraph ) )
128128
129129export const queryBlameHunks = memoizeAsync (
130- async ( { uri, sourcegraph } : { uri : string ; sourcegraph : typeof import ( 'sourcegraph' ) } ) : Promise < Hunk [ ] > => {
130+ async ( {
131+ uri,
132+ sourcegraph,
133+ selections,
134+ } : {
135+ uri : string
136+ sourcegraph : typeof import ( 'sourcegraph' )
137+ selections : Selection [ ] | null
138+ } ) : Promise < Hunk [ ] > => {
131139 const { repo, rev, path } = resolveURI ( uri )
132140 const { data, errors } = await sourcegraph . commands . executeCommand (
133141 'queryGraphQL' ,
134142 gql `
135- query GitBlame($repo: String!, $rev: String!, $path: String!) {
143+ query GitBlame($repo: String!, $rev: String!, $path: String!, $startLine: Int!, $endLine: Int! ) {
136144 repository(name: $repo) {
137145 commit(rev: $rev) {
138146 blob(path: $path) {
139- blame(startLine: 0 , endLine: 0 ) {
147+ blame(startLine: $startLine , endLine: $endLine ) {
140148 startLine
141149 endLine
142150 author {
@@ -160,7 +168,13 @@ export const queryBlameHunks = memoizeAsync(
160168 }
161169 }
162170 ` ,
163- { repo, rev, path }
171+ {
172+ repo,
173+ rev,
174+ path,
175+ startLine : selections ? selections [ 0 ] . start . line + 1 : 0 ,
176+ endLine : selections ? selections [ 0 ] . end . line + 1 : 0 ,
177+ }
164178 )
165179 if ( errors && errors . length > 0 ) {
166180 throw new Error ( errors . join ( '\n' ) )
@@ -170,7 +184,12 @@ export const queryBlameHunks = memoizeAsync(
170184 }
171185 return data . repository . commit . blob . blame
172186 } ,
173- ( { uri } ) => uri
187+ ( { uri, selections } ) => {
188+ if ( selections ) {
189+ return [ uri , selections [ 0 ] . start . line , selections [ 0 ] . end . line ] . join ( ':' )
190+ }
191+ return uri
192+ }
174193)
175194
176195/**
0 commit comments