diff --git a/core/indexing/walkDir.ts b/core/indexing/walkDir.ts index 45dc5d1c0..9289f9960 100644 --- a/core/indexing/walkDir.ts +++ b/core/indexing/walkDir.ts @@ -220,12 +220,12 @@ export async function walkDir( for await (const e of dfsWalker.walk()) { relativePaths.push(e); } - if (options?.returnRelativePaths) { - return relativePaths; - } + const pathSep = await ide.pathSep(); + const prefix = options.returnRelativePaths ? "" : (path + pathSep); + if (pathSep === "/") { - return relativePaths.map((p) => path + pathSep + p); + return relativePaths.map((p) => prefix + p); } - return relativePaths.map((p) => path + pathSep + p.split("/").join(pathSep)); + return relativePaths.map((p) => prefix + p.split("/").join(pathSep)); } diff --git a/core/test/walkDir.test.ts b/core/test/walkDir.test.ts index c3f40128a..87f643f4e 100644 --- a/core/test/walkDir.test.ts +++ b/core/test/walkDir.test.ts @@ -24,6 +24,13 @@ async function expectPaths( toNotExist: string[], options?: WalkerOptions, ) { + // Convert to Windows paths + const pathSep = await ide.pathSep(); + if (pathSep === "\\") { + toExist = toExist.map((p) => p.replace(/\//g, "\\")); + toNotExist = toNotExist.map((p) => p.replace(/\//g, "\\")); + } + const result = await walkTestDir(options); for (const p of toExist) {