@@ -30,7 +30,7 @@ export class CommandHandler {
3030 async ( progress , token ) => {
3131 try {
3232 this . output . clear ( ) ;
33- return this . handleImportBasedCollection (
33+ await this . handleImportBasedCollection (
3434 uri ,
3535 selectedFiles ,
3636 token ,
@@ -59,7 +59,7 @@ export class CommandHandler {
5959 async ( progress , token ) => {
6060 try {
6161 this . output . clear ( ) ;
62- return this . handleDirectCollection ( uri , selectedFiles , token ) ;
62+ await this . handleDirectCollection ( uri , selectedFiles , token ) ;
6363 } catch ( error ) {
6464 const errorMessage = `Error: ${ error } ` ;
6565 this . output . error ( errorMessage , error ) ;
@@ -83,7 +83,7 @@ export class CommandHandler {
8383 async ( progress , token ) => {
8484 try {
8585 this . output . clear ( ) ;
86- return this . handleImportBasedCollection (
86+ await this . handleImportBasedCollection (
8787 uri ,
8888 selectedFiles ,
8989 token ,
@@ -174,13 +174,22 @@ export class CommandHandler {
174174 return ;
175175 }
176176
177- const output = formatContexts ( allContexts ) ;
178177 const totalLines = allContexts . reduce (
179178 ( sum , ctx ) => sum + ctx . content . split ( "\n" ) . length ,
180179 0 ,
181180 ) ;
182181 const stats = getFileTypeStats ( allContexts ) ;
183- await vscode . env . clipboard . writeText ( output ) ;
182+
183+ try {
184+ const output = formatContexts ( allContexts ) ;
185+ await vscode . env . clipboard . writeText ( output ) ;
186+ } catch ( error ) {
187+ const message = "Content too large to copy to clipboard" ;
188+ this . output . error ( message , error ) ;
189+ vscode . window . showWarningMessage (
190+ `${ message } . Collected ${ allContexts . length } files but cannot copy to clipboard.` ,
191+ ) ;
192+ }
184193
185194 showStatsNotification (
186195 allContexts . length ,
@@ -264,13 +273,22 @@ export class CommandHandler {
264273 ) ;
265274 }
266275
267- const output = formatContexts ( finalContexts ) ;
268276 const totalLines = finalContexts . reduce (
269277 ( sum , ctx ) => sum + ctx . content . split ( "\n" ) . length ,
270278 0 ,
271279 ) ;
272280 const stats = getFileTypeStats ( finalContexts ) ;
273- await vscode . env . clipboard . writeText ( output ) ;
281+
282+ try {
283+ const output = formatContexts ( finalContexts ) ;
284+ await vscode . env . clipboard . writeText ( output ) ;
285+ } catch ( error ) {
286+ const message = "Content too large to copy to clipboard" ;
287+ this . output . error ( message , error ) ;
288+ vscode . window . showWarningMessage (
289+ `${ message } . Collected ${ finalContexts . length } files but cannot copy to clipboard.` ,
290+ ) ;
291+ }
274292
275293 const modeLabel = applyIgnorePatterns
276294 ? "smart filter"
@@ -360,8 +378,17 @@ export class CommandHandler {
360378 0 ,
361379 ) ;
362380 const stats = getFileTypeStats ( uniqueContexts ) ;
363- const output = formatContexts ( uniqueContexts ) ;
364- await vscode . env . clipboard . writeText ( output ) ;
381+
382+ try {
383+ const output = formatContexts ( uniqueContexts ) ;
384+ await vscode . env . clipboard . writeText ( output ) ;
385+ } catch ( error ) {
386+ const message = "Content too large to copy to clipboard" ;
387+ this . output . error ( message , error ) ;
388+ vscode . window . showWarningMessage (
389+ `${ message } . Collected ${ uniqueContexts . length } files but cannot copy to clipboard.` ,
390+ ) ;
391+ }
365392
366393 showStatsNotification (
367394 uniqueContexts . length ,
0 commit comments