@@ -57,7 +57,8 @@ async function generateAndUpdateMarkdown(markdownPreviewProvider: MarkdownPrevie
5757 markdownPreviewProvider . updateContent ( "Generating markdown..." ) ;
5858 const config = vscode . workspace . getConfiguration ( "recursiveMarkdownGenerator" ) ;
5959 const ig = await createIgnoreFilter ( config , workspaceFolder . uri . fsPath ) ;
60- const fileInfos = await collectFileInfos ( workspaceFolder . uri . fsPath , ig ) ;
60+ const maxFileSize = config . get ( "maxFileSize" ) || 512000 ; // 500KB in bytes
61+ const fileInfos = await collectFileInfos ( workspaceFolder . uri . fsPath , ig , maxFileSize ) ;
6162 markdownPreviewProvider . generatedMarkdown = generateMarkdownFromFileInfos ( fileInfos ) ;
6263 const htmlContent = convertFileInfosToHtml ( fileInfos ) ;
6364 markdownPreviewProvider . updateContent ( htmlContent ) ;
@@ -86,7 +87,8 @@ async function createIgnoreFilter(config: vscode.WorkspaceConfiguration, workspa
8687 return ig ;
8788}
8889
89- async function collectFileInfos ( directory : string , ig : ReturnType < typeof ignore > ) : Promise < FileInfo [ ] > {
90+ async function collectFileInfos ( directory : string , ig : ReturnType < typeof ignore > , maxFileSize : number ) : Promise < FileInfo [ ] > {
91+
9092 // Use the new glob API
9193 const files = await glob ( "**/*" , {
9294 cwd : directory ,
@@ -105,6 +107,18 @@ async function collectFileInfos(directory: string, ig: ReturnType<typeof ignore>
105107 return null ;
106108 }
107109
110+ // Check file size and skip if too large
111+ try {
112+ const stats = await fs . stat ( filePath ) ;
113+ if ( stats . size > maxFileSize ) {
114+ console . log ( `Skipping large file (${ stats . size } bytes > ${ maxFileSize } bytes): ${ normalizedPath } ` ) ;
115+ return null ;
116+ }
117+ } catch ( error ) {
118+ console . error ( `Error getting file stats ${ filePath } :` , error ) ;
119+ return null ;
120+ }
121+
108122 const fileExtension = path . extname ( filePath ) . toLowerCase ( ) ;
109123
110124 // Special handling for docx files
0 commit comments