@@ -43,7 +43,7 @@ export async function listFiles(dirPath: string, recursive: boolean, limit: numb
4343 if ( recursive ) {
4444 allAbsolutePaths = await listAllFilesRecursively ( absoluteDirPath , git , workspacePath , limit + 1 )
4545 } else {
46- allAbsolutePaths = await listNonRecursive ( absoluteDirPath , git , workspacePath )
46+ allAbsolutePaths = await listNonRecursive ( absoluteDirPath , git , workspacePath , limit + 1 )
4747 }
4848
4949 // Filter out any empty strings and apply the custom ignore list as a final pass.
@@ -218,12 +218,12 @@ function createGitignoreFilter(rootDir: string) {
218218 * List only top-level files and directories, filtering out ignored ones.
219219 * Uses ripgrep for performance and consistency with recursive listing.
220220 */
221- async function listNonRecursive ( dir : string , _git : SimpleGit , workspacePath : string ) : Promise < string [ ] > {
221+ async function listNonRecursive ( dir : string , _git : SimpleGit , workspacePath : string , limit : number ) : Promise < string [ ] > {
222222 const ig = createGitignoreFilter ( workspacePath )
223223
224224 let files : string [ ] = [ ]
225225 try {
226- files = await listFilesWithRipgrep ( dir , false , 10000 )
226+ files = await listFilesWithRipgrep ( dir , false , limit )
227227 } catch ( err ) {
228228 console . warn ( "listFilesWithRipgrep (non-recursive) failed:" , err )
229229 }
@@ -257,6 +257,6 @@ async function listNonRecursive(dir: string, _git: SimpleGit, workspacePath: str
257257 }
258258
259259 // Enforce limit after combining files and directories
260- const combined = [ ...filtered . map ( ( rel ) => path . join ( workspacePath , rel ) ) , ... dirEntries ]
261- return combined . slice ( 0 , 10000 ) // 10000 is the same as above, will be sliced by caller
260+ const combined = [ ...dirEntries , ... filtered . map ( ( rel ) => path . join ( workspacePath , rel ) ) ]
261+ return combined . slice ( 0 , limit )
262262}
0 commit comments