@@ -7,7 +7,7 @@ import * as vscode from 'vscode';
77import * as pathUtils from 'path' ;
88
99const FILE_LINE_REGEX = / ^ ( \S .* ) : $ / ;
10- const RESULT_LINE_REGEX = / ^ ( \s + ) ( \d + ) ( : | ) ( \s + ) ( .* ) $ / ;
10+ const RESULT_LINE_REGEX = / ^ ( \s + ) ( \d + ) ( : | ) ( \s * ) ( .* ) $ / ;
1111const ELISION_REGEX = / ⟪ ( [ 0 - 9 ] + ) c h a r a c t e r s s k i p p e d ⟫ / g;
1212const SEARCH_RESULT_SELECTOR = { language : 'search-result' , exclusive : true } ;
1313const DIRECTIVES = [ '# Query:' , '# Flags:' , '# Including:' , '# Excluding:' , '# ContextLines:' ] ;
@@ -220,10 +220,9 @@ function parseSearchResults(document: vscode.TextDocument, token?: vscode.Cancel
220220
221221 const resultLine = RESULT_LINE_REGEX . exec ( line ) ;
222222 if ( resultLine ) {
223- const [ , indentation , _lineNumber , seperator , resultIndentation ] = resultLine ;
223+ const [ , indentation , _lineNumber , separator ] = resultLine ;
224224 const lineNumber = + _lineNumber - 1 ;
225- const resultStart = ( indentation + _lineNumber + seperator + resultIndentation ) . length ;
226- const metadataOffset = ( indentation + _lineNumber + seperator ) . length ;
225+ const metadataOffset = ( indentation + _lineNumber + separator ) . length ;
227226 const targetRange = new vscode . Range ( Math . max ( lineNumber - 3 , 0 ) , 0 , lineNumber + 3 , line . length ) ;
228227
229228 let locations : Required < vscode . LocationLink > [ ] = [ ] ;
@@ -233,12 +232,12 @@ function parseSearchResults(document: vscode.TextDocument, token?: vscode.Cancel
233232 targetRange,
234233 targetSelectionRange : new vscode . Range ( lineNumber , 0 , lineNumber , 1 ) ,
235234 targetUri : currentTarget ,
236- originSelectionRange : new vscode . Range ( i , 0 , i , resultStart ) ,
235+ originSelectionRange : new vscode . Range ( i , 0 , i , metadataOffset - 1 ) ,
237236 } ) ;
238237
239- let lastEnd = resultStart ;
238+ let lastEnd = metadataOffset ;
240239 let offset = 0 ;
241- ELISION_REGEX . lastIndex = resultStart ;
240+ ELISION_REGEX . lastIndex = metadataOffset ;
242241 for ( let match : RegExpExecArray | null ; ( match = ELISION_REGEX . exec ( line ) ) ; ) {
243242 locations . push ( {
244243 targetRange,
@@ -261,7 +260,7 @@ function parseSearchResults(document: vscode.TextDocument, token?: vscode.Cancel
261260 }
262261
263262 currentTargetLocations ?. push ( ...locations ) ;
264- links [ i ] = { type : 'result' , locations, isContext : seperator === ' ' , prefixRange : new vscode . Range ( i , 0 , i , metadataOffset ) } ;
263+ links [ i ] = { type : 'result' , locations, isContext : separator === ' ' , prefixRange : new vscode . Range ( i , 0 , i , metadataOffset ) } ;
265264 }
266265 }
267266
0 commit comments