@@ -5,6 +5,7 @@ import * as tmp from 'tmp-promise';
55import {
66 CancellationToken ,
77 ConfigurationTarget ,
8+ Range ,
89 TextDocument ,
910 TextEditor ,
1011 Uri ,
@@ -327,17 +328,17 @@ async function convertToQlPath(filePath: string): Promise<string> {
327328
328329
329330/** Gets the selected position within the given editor. */
330- async function getSelectedPosition ( editor : TextEditor , args ?: any ) : Promise < messages . Position > {
331- const pos = args [ 0 ] . start ;
332- const posEnd = args [ 0 ] . end ;
333- const argsLength = args [ 1 ] + 10 ;
331+ async function getSelectedPosition ( editor : TextEditor , args ?: Range ) : Promise < messages . Position > {
332+ const range = args || editor . selection ;
333+ const pos = range . start ;
334+ const posEnd = range . end ;
334335 // Convert from 0-based to 1-based line and column numbers.
335336 return {
336337 fileName : await convertToQlPath ( editor . document . fileName ) ,
337338 line : pos . line + 1 ,
338- column : pos . character + argsLength ,
339+ column : pos . character + 1 ,
339340 endLine : posEnd . line + 1 ,
340- endColumn : posEnd . character - argsLength
341+ endColumn : posEnd . character + 1
341342 } ;
342343}
343344
@@ -486,7 +487,7 @@ type SelectedQuery = {
486487 * @param selectedResourceUri The selected resource when the command was run.
487488 * @param quickEval Whether the command being run is `Quick Evaluation`.
488489*/
489- export async function determineSelectedQuery ( selectedResourceUri : Uri | undefined , quickEval : boolean , args ?: any ) : Promise < SelectedQuery > {
490+ export async function determineSelectedQuery ( selectedResourceUri : Uri | undefined , quickEval : boolean , args ?: Range ) : Promise < SelectedQuery > {
490491 const editor = window . activeTextEditor ;
491492
492493 // Choose which QL file to use.
@@ -555,8 +556,8 @@ export async function compileAndRunQueryAgainstDatabase(
555556 selectedQueryUri : Uri | undefined ,
556557 progress : ProgressCallback ,
557558 token : CancellationToken ,
558- args ?: any ,
559559 templates ?: messages . TemplateDefinitions ,
560+ args ?: Range
560561) : Promise < QueryWithResults > {
561562 if ( ! db . contents || ! db . contents . dbSchemeUri ) {
562563 throw new Error ( `Database ${ db . databaseUri } does not have a CodeQL database scheme.` ) ;
0 commit comments