File tree Expand file tree Collapse file tree 10 files changed +34
-15
lines changed
intellij/src/main/kotlin/com/github/continuedev/continueintellijextension Expand file tree Collapse file tree 10 files changed +34
-15
lines changed Original file line number Diff line number Diff line change @@ -783,7 +783,7 @@ export interface IDE {
783783
784784 getSearchResults ( query : string ) : Promise < string > ;
785785
786- getFileResults ( pattern : string ) : Promise < string [ ] > ;
786+ getFileResults ( pattern : string , maxResults ?: number ) : Promise < string [ ] > ;
787787
788788 subprocess ( command : string , cwd ?: string ) : Promise < [ string , string ] > ;
789789
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export type ToIdeFromWebviewOrCoreProtocol = {
3030 openUrl : [ string , void ] ;
3131 runCommand : [ { command : string ; options ?: TerminalOptions } , void ] ;
3232 getSearchResults : [ { query : string } , string ] ;
33- getFileResults : [ { pattern : string } , string [ ] ] ;
33+ getFileResults : [ { pattern : string ; maxResults ?: number } , string [ ] ] ;
3434 subprocess : [ { command : string ; cwd ?: string } , [ string , string ] ] ;
3535 saveFile : [ { filepath : string } , void ] ;
3636 fileExists : [ { filepath : string } , boolean ] ;
Original file line number Diff line number Diff line change @@ -163,7 +163,7 @@ export class ReverseMessageIde {
163163 } ) ;
164164
165165 this . on ( "getFileResults" , ( data ) => {
166- return this . ide . getFileResults ( data . pattern ) ;
166+ return this . ide . getFileResults ( data . pattern , data . maxResults ) ;
167167 } ) ;
168168
169169 this . on ( "getProblems" , ( data ) => {
Original file line number Diff line number Diff line change @@ -238,7 +238,10 @@ class FileSystemIde implements IDE {
238238 return "" ;
239239 }
240240
241- async getFileResults ( pattern : string ) : Promise < string [ ] > {
241+ async getFileResults (
242+ pattern : string ,
243+ maxResults ?: number ,
244+ ) : Promise < string [ ] > {
242245 return [ ] ;
243246 }
244247
Original file line number Diff line number Diff line change @@ -365,7 +365,7 @@ class IdeProtocolClient(
365365 dataElement.toString(),
366366 GetFileResultsParams ::class .java
367367 )
368- val results = ide.getFileResults(params.pattern)
368+ val results = ide.getFileResults(params.pattern, params.maxResults )
369369 respond(results)
370370 }
371371
Original file line number Diff line number Diff line change @@ -315,20 +315,26 @@ class IntelliJIDE(
315315 return getOpenFiles()
316316 }
317317
318- override suspend fun getFileResults (pattern : String ): List <String > {
318+ override suspend fun getFileResults (pattern : String , maxResults : Int? ): List <String > {
319319 val ideInfo = this .getIdeInfo()
320320 if (ideInfo.remoteName == " local" ) {
321321 try {
322- val command = GeneralCommandLine (
322+ var commandArgs = mutableListOf< String > (
323323 ripgrep,
324324 " --files" ,
325325 " --iglob" ,
326326 pattern,
327327 " --ignore-file" ,
328328 " .continueignore" ,
329329 " --ignore-file" ,
330- " .gitignore" ,
330+ " .gitignore"
331331 )
332+ if (maxResults != null ) {
333+ commandArgs.add(" --max-count" )
334+ commandArgs.add(maxResults.toString())
335+ }
336+
337+ val command = GeneralCommandLine (commandArgs)
332338
333339 command.setWorkDirectory(project.basePath)
334340 val results = ExecUtil .execAndGetOutput(command).stdout
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ typealias getTagsParams = String
2323
2424data class GetSearchResultsParams (val query : String )
2525
26- data class GetFileResultsParams (val pattern : String )
26+ data class GetFileResultsParams (val pattern : String , val maxResults : Int? )
2727
2828data class SaveFileParams (val filepath : String )
2929
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ interface IDE {
159159
160160 suspend fun getSearchResults (query : String ): String
161161
162- suspend fun getFileResults (pattern : String ): List <String >
162+ suspend fun getFileResults (pattern : String , maxResults : Int? ): List <String >
163163
164164 // Note: This should be a `Pair<String, String>` but we use `List<Any>` because the keys of `Pair`
165165 // will serialize to `first and `second` rather than `0` and `1` like in JavaScript
Original file line number Diff line number Diff line change @@ -433,8 +433,10 @@ class VsCodeIde implements IDE {
433433 } ) ;
434434 }
435435
436- async getFileResults ( pattern : string ) : Promise < string [ ] > {
437- const MAX_FILE_RESULTS = 200 ;
436+ async getFileResults (
437+ pattern : string ,
438+ maxResults ?: number ,
439+ ) : Promise < string [ ] > {
438440 if ( vscode . env . remoteName ) {
439441 // TODO better tests for this remote search implementation
440442 // throw new Error("Ripgrep not supported, this workspace is remote");
@@ -501,7 +503,7 @@ class VsCodeIde implements IDE {
501503 const results = await vscode . workspace . findFiles (
502504 pattern ,
503505 ignoreGlobs . size ? `{${ ignoreGlobsArray . join ( "," ) } }` : null ,
504- MAX_FILE_RESULTS ,
506+ maxResults ,
505507 ) ;
506508 return results . map ( ( result ) => vscode . workspace . asRelativePath ( result ) ) ;
507509 } else {
@@ -515,12 +517,20 @@ class VsCodeIde implements IDE {
515517 ".continueignore" ,
516518 "--ignore-file" ,
517519 ".gitignore" ,
520+ ...( maxResults ? [ "--max-count" , String ( maxResults ) ] : [ ] ) ,
518521 ] ) ;
519522
520523 results . push ( dirResults ) ;
521524 }
522525
523- return results . join ( "\n" ) . split ( "\n" ) . slice ( 0 , MAX_FILE_RESULTS ) ;
526+ const allResults = results . join ( "\n" ) . split ( "\n" ) ;
527+ if ( maxResults ) {
528+ // In the case of multiple workspaces, maxResults will be applied to each workspace
529+ // And then the combined results will also be truncated
530+ return allResults . slice ( 0 , maxResults ) ;
531+ } else {
532+ return allResults ;
533+ }
524534 }
525535 }
526536
Original file line number Diff line number Diff line change @@ -324,7 +324,7 @@ export class VsCodeMessenger {
324324 return ide . getSearchResults ( msg . data . query ) ;
325325 } ) ;
326326 this . onWebviewOrCore ( "getFileResults" , async ( msg ) => {
327- return ide . getFileResults ( msg . data . pattern ) ;
327+ return ide . getFileResults ( msg . data . pattern , msg . data . maxResults ) ;
328328 } ) ;
329329 this . onWebviewOrCore ( "subprocess" , async ( msg ) => {
330330 return ide . subprocess ( msg . data . command , msg . data . cwd ) ;
You can’t perform that action at this time.
0 commit comments