Skip to content

Commit a80ae37

Browse files
committed
Sorting workspace folders in ziputils for test generation usecase.
1 parent eab6f5c commit a80ae37

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

packages/core/src/codewhisperer/util/zipUtil.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,9 @@ export class ZipUtil {
412412

413413
const sourceFiles = await collectFiles(
414414
projectPaths,
415-
vscode.workspace.workspaceFolders as CurrentWsFolders,
415+
[...(vscode.workspace.workspaceFolders ?? [])].sort(
416+
(a, b) => b.uri.fsPath.length - a.uri.fsPath.length
417+
) as CurrentWsFolders,
416418
{
417419
maxSizeBytes: this.getProjectScanPayloadSizeLimitInBytes(),
418420
},

packages/core/src/shared/utilities/workspaceUtils.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,12 @@ export function getWorkspaceRelativePath(
224224
workspaceFolders?: readonly vscode.WorkspaceFolder[]
225225
} = {
226226
workspaceFolders: vscode.workspace.workspaceFolders,
227-
},
228-
useCase?: FeatureUseCase
227+
}
229228
): { relativePath: string; workspaceFolder: vscode.WorkspaceFolder } | undefined {
230229
if (!override.workspaceFolders) {
231230
return
232231
}
233232
let folders = override.workspaceFolders
234-
if (useCase && useCase === FeatureUseCase.TEST_GENERATION) {
235-
// Sort workspace folders by path length (descending) to prioritize deeper paths
236-
// TODO: Need to enable this for entire Q
237-
folders = [...override.workspaceFolders].sort((a, b) => b.uri.fsPath.length - a.uri.fsPath.length)
238-
}
239233

240234
for (const folder of folders) {
241235
if (isInDirectory(folder.uri.fsPath, childPath)) {
@@ -410,10 +404,10 @@ export async function collectFiles(
410404
excludePatternFilter
411405
)
412406

413-
const files = excludeByGitIgnore ? await filterOutGitignoredFiles(rootPath, allFiles, false) : allFiles
407+
const files = excludeByGitIgnore ? await filterOutGitignoredFiles(rootPath, allFiles, false, useCase) : allFiles
414408

415409
for (const file of files) {
416-
const relativePath = getWorkspaceRelativePath(file.fsPath, { workspaceFolders }, useCase)
410+
const relativePath = getWorkspaceRelativePath(file.fsPath, { workspaceFolders })
417411
if (!relativePath) {
418412
continue
419413
}

0 commit comments

Comments
 (0)