Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/test/simulation/fixtures/multiFileEdit/filepaths/1.ts
13405 views
1
import * as fs from 'fs';
2
import * as path from 'path';
3
import * as vscode from 'vscode';
4
5
export async function findParentFolder(relativeFilePath: string): Promise<string | null> {
6
const workspaceFolders = vscode.workspace.workspaceFolders;
7
8
if (!workspaceFolders) {
9
console.error('No workspace folders found');
10
return null;
11
}
12
13
for (const folder of workspaceFolders) {
14
const fullPath = path.join(folder.uri.fsPath, relativeFilePath);
15
16
try {
17
const stats = await fs.promises.stat(fullPath);
18
if (stats.isFile()) {
19
return folder.uri.fsPath;
20
}
21
} catch (err) {
22
// File does not exist in this folder, continue to next
23
}
24
}
25
26
return null;
27
}
28