@@ -63,21 +63,26 @@ export class ChatInstructionsFileLocator {
63
63
// otherwise for each folder provided in the configuration, create
64
64
// a URI per each folder in the current workspace
65
65
const { folders } = this . workspaceService . getWorkspace ( ) ;
66
+ const workspaceRootUri = dirname ( folders [ 0 ] . uri ) ;
66
67
for ( const folder of folders ) {
67
68
for ( const sourceFolderName of sourceLocations ) {
68
- const folderUri = extUri . resolvePath ( folder . uri , sourceFolderName ) ;
69
- result . push ( folderUri ) ;
70
- }
71
- }
69
+ // create the source path as a path relative to the workspace
70
+ // folder, or as an absolute path if the absolute value is provided
71
+ const sourceFolderUri = extUri . resolvePath ( folder . uri , sourceFolderName ) ;
72
+ result . push ( sourceFolderUri ) ;
72
73
73
- // if inside a workspace, add the specified source locations inside the workspace
74
- // root too, to allow users to use `.copilot/prompts` folder (or whatever they
75
- // specify in the setting) in the workspace root
76
- if ( folders . length > 1 ) {
77
- const workspaceRootUri = dirname ( folders [ 0 ] . uri ) ;
78
- for ( const sourceFolderName of sourceLocations ) {
79
- const folderUri = extUri . resolvePath ( workspaceRootUri , sourceFolderName ) ;
80
- result . push ( folderUri ) ;
74
+ // if not inside a workspace, we are done
75
+ if ( folders . length <= 1 ) {
76
+ continue ;
77
+ }
78
+
79
+ // if inside a workspace, consider the specified source location inside
80
+ // the workspace root, to allow users to use some (e.g., `.github/prompts`)
81
+ // folder as a top-level folder in the workspace
82
+ const workspaceFolderUri = extUri . resolvePath ( workspaceRootUri , sourceFolderName ) ;
83
+ if ( workspaceFolderUri . fsPath . startsWith ( folder . uri . fsPath ) ) {
84
+ result . push ( workspaceFolderUri ) ;
85
+ }
81
86
}
82
87
}
83
88
0 commit comments