Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,26 @@ export class ChatInstructionsFileLocator {
// otherwise for each folder provided in the configuration, create
// a URI per each folder in the current workspace
const { folders } = this.workspaceService.getWorkspace();
const workspaceRootUri = dirname(folders[0].uri);
for (const folder of folders) {
for (const sourceFolderName of sourceLocations) {
const folderUri = extUri.resolvePath(folder.uri, sourceFolderName);
result.push(folderUri);
}
}
// create the source path as a path relative to the workspace
// folder, or as an absolute path if the absolute value is provided
const sourceFolderUri = extUri.resolvePath(folder.uri, sourceFolderName);
result.push(sourceFolderUri);

// if inside a workspace, add the specified source locations inside the workspace
// root too, to allow users to use `.copilot/prompts` folder (or whatever they
// specify in the setting) in the workspace root
if (folders.length > 1) {
const workspaceRootUri = dirname(folders[0].uri);
for (const sourceFolderName of sourceLocations) {
const folderUri = extUri.resolvePath(workspaceRootUri, sourceFolderName);
result.push(folderUri);
// if not inside a workspace, we are done
if (folders.length <= 1) {
continue;
}

// if inside a workspace, consider the specified source location inside
// the workspace root, to allow users to use some (e.g., `.github/prompts`)
// folder as a top-level folder in the workspace
const workspaceFolderUri = extUri.resolvePath(workspaceRootUri, sourceFolderName);
if (workspaceFolderUri.fsPath.startsWith(folder.uri.fsPath)) {
result.push(workspaceFolderUri);
}
}
}

Expand Down