File tree Expand file tree Collapse file tree 3 files changed +28
-11
lines changed
amazonq/.changes/next-release
core/src/amazonqFeatureDev Expand file tree Collapse file tree 3 files changed +28
-11
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "type" : " Bug Fix" ,
3+ "description" : " Amazon Q /dev: define first folder as a root path for LLM-created files when using workspaces"
4+ }
Original file line number Diff line number Diff line change @@ -68,7 +68,13 @@ function registerNewFiles(
6868 fs . registerProvider ( uri , new VirtualMemoryFile ( contents ) )
6969 const prefix =
7070 workspaceFolderPrefixes === undefined ? '' : zipFilePath . substring ( 0 , zipFilePath . indexOf ( path . sep ) )
71- const folder = workspaceFolderPrefixes === undefined ? workspaceFolders [ 0 ] : workspaceFolderPrefixes [ prefix ]
71+ const folder =
72+ workspaceFolderPrefixes === undefined
73+ ? workspaceFolders [ 0 ]
74+ : workspaceFolderPrefixes [ prefix ] ??
75+ workspaceFolderPrefixes [
76+ Object . values ( workspaceFolderPrefixes ) . find ( ( val ) => val . index === 0 ) ?. name ?? ''
77+ ]
7278 if ( folder === undefined ) {
7379 getLogger ( ) . error ( `No workspace folder found for file: ${ zipFilePath } and prefix: ${ prefix } ` )
7480 continue
@@ -78,7 +84,9 @@ function registerNewFiles(
7884 fileContent,
7985 virtualMemoryUri : uri ,
8086 workspaceFolder : folder ,
81- relativePath : zipFilePath . substring ( workspaceFolderPrefixes === undefined ? 0 : prefix . length + 1 ) ,
87+ relativePath : zipFilePath . substring (
88+ workspaceFolderPrefixes === undefined ? 0 : prefix . length > 0 ? prefix . length + 1 : 0
89+ ) ,
8290 rejected : false ,
8391 } )
8492 }
Original file line number Diff line number Diff line change @@ -63,15 +63,18 @@ export async function prepareRepoData(
6363 const iterator = ignoredExtensionMap . entries ( )
6464
6565 for ( let i = 0 ; i < ignoredExtensionMap . size ; i ++ ) {
66- const [ key , value ] = iterator . next ( ) . value
67- await amznTelemetry . amazonq_bundleExtensionIgnored . run ( async ( bundleSpan ) => {
68- const event = {
69- filenameExt : key ,
70- count : value ,
71- }
66+ const iteratorValue = iterator . next ( ) . value
67+ if ( iteratorValue ) {
68+ const [ key , value ] = iteratorValue
69+ await amznTelemetry . amazonq_bundleExtensionIgnored . run ( async ( bundleSpan ) => {
70+ const event = {
71+ filenameExt : key ,
72+ count : value ,
73+ }
7274
73- bundleSpan . record ( event )
74- } )
75+ bundleSpan . record ( event )
76+ } )
77+ }
7578 }
7679
7780 telemetry . setRepositorySize ( totalBytes )
@@ -117,7 +120,9 @@ export function getPathsFromZipFilePath(
117120 }
118121 // otherwise the first part of the zipPath is the prefix
119122 const prefix = zipFilePath . substring ( 0 , zipFilePath . indexOf ( path . sep ) )
120- const workspaceFolder = workspacesByPrefix [ prefix ]
123+ const workspaceFolder =
124+ workspacesByPrefix [ prefix ] ??
125+ ( workspacesByPrefix [ Object . values ( workspacesByPrefix ) . find ( ( val ) => val . index === 0 ) ?. name ?? '' ] || undefined )
121126 if ( workspaceFolder === undefined ) {
122127 throw new ToolkitError ( `Could not find workspace folder for prefix ${ prefix } ` )
123128 }
You can’t perform that action at this time.
0 commit comments