Files
vscode/extensions/copilot/test/simulation/fixtures/multiFileEdit/filepaths/1.ts
T
kieferrm 333d9a4053 Hello Copilot
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2025-06-27 11:35:20 +02:00

27 lines
665 B
TypeScript

import * as fs from 'fs';
import * as path from 'path';
import * as vscode from 'vscode';
export async function findParentFolder(relativeFilePath: string): Promise<string | null> {
const workspaceFolders = vscode.workspace.workspaceFolders;
if (!workspaceFolders) {
console.error('No workspace folders found');
return null;
}
for (const folder of workspaceFolders) {
const fullPath = path.join(folder.uri.fsPath, relativeFilePath);
try {
const stats = await fs.promises.stat(fullPath);
if (stats.isFile()) {
return folder.uri.fsPath;
}
} catch (err) {
// File does not exist in this folder, continue to next
}
}
return null;
}