@@ -23,7 +23,9 @@ import { KeyType } from "./key-type";
2323import {
2424 FullLocationLink ,
2525 getLocationsForUriString ,
26- TEMPLATE_NAME ,
26+ SELECTED_SOURCE_FILE ,
27+ SELECTED_SOURCE_LINE ,
28+ SELECTED_SOURCE_COLUMN ,
2729} from "./location-finder" ;
2830import {
2931 qlpackOfDatabase ,
@@ -253,7 +255,7 @@ export class TemplatePrintAstProvider {
253255
254256 const query = queries [ 0 ] ;
255257 const templates : Record < string , string > = {
256- [ TEMPLATE_NAME ] : zippedArchive . pathWithinSourceArchive ,
258+ [ SELECTED_SOURCE_FILE ] : zippedArchive . pathWithinSourceArchive ,
257259 } ;
258260
259261 const results = await runContextualQuery (
@@ -284,15 +286,17 @@ export class TemplatePrintCfgProvider {
284286 }
285287
286288 async provideCfgUri (
287- document ?: TextDocument ,
289+ document : TextDocument ,
290+ line : number ,
291+ character : number ,
288292 ) : Promise < [ Uri , Record < string , string > ] | undefined > {
289- if ( ! document ) {
290- return ;
291- }
292-
293293 return this . shouldUseCache ( )
294- ? await this . cache . get ( document . uri . toString ( ) )
295- : await this . getCfgUri ( document . uri . toString ( ) ) ;
294+ ? await this . cache . get (
295+ `${ document . uri . toString ( ) } #${ line } :${ character } ` ,
296+ line ,
297+ character ,
298+ )
299+ : await this . getCfgUri ( document . uri . toString ( ) , line , character ) ;
296300 }
297301
298302 private shouldUseCache ( ) {
@@ -301,6 +305,8 @@ export class TemplatePrintCfgProvider {
301305
302306 private async getCfgUri (
303307 uriString : string ,
308+ line : number ,
309+ character : number ,
304310 ) : Promise < [ Uri , Record < string , string > ] > {
305311 const uri = Uri . parse ( uriString , true ) ;
306312 if ( uri . scheme !== zipArchiveScheme ) {
@@ -342,7 +348,9 @@ export class TemplatePrintCfgProvider {
342348 const queryUri = Uri . file ( queries [ 0 ] ) ;
343349
344350 const templates : Record < string , string > = {
345- [ TEMPLATE_NAME ] : zippedArchive . pathWithinSourceArchive ,
351+ [ SELECTED_SOURCE_FILE ] : zippedArchive . pathWithinSourceArchive ,
352+ [ SELECTED_SOURCE_LINE ] : line . toString ( ) ,
353+ [ SELECTED_SOURCE_COLUMN ] : character . toString ( ) ,
346354 } ;
347355
348356 return [ queryUri , templates ] ;
0 commit comments