mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-06 08:18:39 +00:00
fix: apply numeric-aware sorting before limit in formatAndCombineResults
The previous implementation removed sorting entirely, which caused version-numbered files to be excluded when directories had 200+ files. This fix applies numeric-aware sorting (using localeCompare with numeric option) before the limit is applied, ensuring proper ordering of version sequences like v3.25, v3.25.1, v3.25.2, etc.
This commit is contained in:
parent
ab481eac18
commit
9da8c7ed54
1 changed files with 14 additions and 2 deletions
|
|
@ -601,8 +601,20 @@ function formatAndCombineResults(files: string[], directories: string[], limit:
|
|||
const uniquePathsSet = new Set(allPaths)
|
||||
const uniquePaths = Array.from(uniquePathsSet)
|
||||
|
||||
// Note: Sorting is handled by formatFilesList with numeric-aware algorithm
|
||||
// to properly handle version-numbered files (e.g., v3.25.1, v3.25.2, etc.)
|
||||
// Apply numeric-aware sorting before limiting results
|
||||
// This ensures version-numbered files are properly ordered before truncation
|
||||
uniquePaths.sort((a: string, b: string) => {
|
||||
const aIsDir = a.endsWith("/")
|
||||
const bIsDir = b.endsWith("/")
|
||||
|
||||
// Directories come first
|
||||
if (aIsDir && !bIsDir) return -1
|
||||
if (!aIsDir && bIsDir) return 1
|
||||
|
||||
// For same type (both dirs or both files), use numeric-aware comparison
|
||||
// This properly handles version numbers like v3.25.1, v3.25.2, etc.
|
||||
return a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" })
|
||||
})
|
||||
|
||||
const trimmedPaths = uniquePaths.slice(0, limit)
|
||||
return [trimmedPaths, trimmedPaths.length >= limit]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue