@@ -130,6 +130,9 @@ export const getSnippets = (
130130 const finalSnippets = [ ] ;
131131 let remainingTokenCount = getRemainingTokenCount ( helper ) ;
132132
133+ // tracks already added filepaths for deduplication
134+ const addedFilepaths = new Set < string > ( ) ;
135+
133136 // Process snippets in priority order
134137 for ( const { key } of snippetOrder ) {
135138 // Special handling for recentlyOpenedFiles
@@ -160,9 +163,10 @@ export const getSnippets = (
160163
161164 if ( remainingTokenCount >= snippetSize ) {
162165 finalSnippets . push ( snippet ) ;
166+ addedFilepaths . add ( snippet . filepath ) ;
163167 remainingTokenCount -= snippetSize ;
164168 } else {
165- break ; // Out of tokens
169+ continue ; // Not enough tokens, try again with next snippet
166170 }
167171 }
168172 } else {
@@ -171,7 +175,9 @@ export const getSnippets = (
171175 ( snippet ) =>
172176 ! ( snippet as AutocompleteCodeSnippet ) . filepath ?. startsWith (
173177 "output:extension-output-Continue.continue" ,
174- ) ,
178+ ) &&
179+ ( ( snippet as AutocompleteCodeSnippet ) . filepath === undefined ||
180+ ! addedFilepaths . has ( ( snippet as AutocompleteCodeSnippet ) . filepath ) ) ,
175181 ) ;
176182
177183 for ( const snippet of snippetsToProcess ) {
@@ -182,9 +188,14 @@ export const getSnippets = (
182188
183189 if ( remainingTokenCount >= snippetSize ) {
184190 finalSnippets . push ( snippet ) ;
191+
192+ if ( ( snippet as AutocompleteCodeSnippet ) . filepath ) {
193+ addedFilepaths . add ( ( snippet as AutocompleteCodeSnippet ) . filepath ) ;
194+ }
195+
185196 remainingTokenCount -= snippetSize ;
186197 } else {
187- break ; // Out of tokens
198+ continue ; // Not enough tokens, try again with next snippet
188199 }
189200 }
190201 }
0 commit comments