@@ -10,14 +10,14 @@ export class FilesCollector {
1010 private open_editors_provider ?: OpenEditorsProvider
1111 private workspace_roots : string [ ] = [ ]
1212
13- constructor (
14- workspace_provider : WorkspaceProvider ,
13+ constructor ( params : {
14+ workspace_provider : WorkspaceProvider
1515 open_editors_provider ?: OpenEditorsProvider
16- ) {
17- this . workspace_provider = workspace_provider
18- this . open_editors_provider = open_editors_provider
16+ } ) {
17+ this . workspace_provider = params . workspace_provider
18+ this . open_editors_provider = params . open_editors_provider
1919
20- this . workspace_roots = workspace_provider . get_workspace_roots ( )
20+ this . workspace_roots = this . workspace_provider . get_workspace_roots ( )
2121 }
2222
2323 async collect_files ( params ?: {
@@ -48,15 +48,11 @@ export class FilesCollector {
4848 }
4949
5050 const context_files = [ ...new Set ( context_files_list ) ]
51- const now = Date . now ( )
52- const THREE_HOURS = 3 * 60 * 60 * 1000
5351
5452 // Sort context files based on modification time and selection timestamp
55- const sorted_context_files = this . _sort_context_files (
56- context_files ,
57- now ,
58- THREE_HOURS
59- )
53+ const sorted_context_files = this . _sort_context_files ( {
54+ files : context_files
55+ } )
6056
6157 let collected_text = ''
6258
@@ -116,15 +112,13 @@ export class FilesCollector {
116112 return this . workspace_provider . get_workspace_root_for_file ( file_path )
117113 }
118114
119- private _sort_context_files (
120- files : string [ ] ,
121- now : number ,
122- three_hours : number
123- ) : string [ ] {
115+ private _sort_context_files ( params : { files : string [ ] } ) : string [ ] {
124116 const recently_modified : Array < { path : string ; mtime : number } > = [ ]
125117 const older_files : Array < { path : string ; timestamp : number } > = [ ]
118+ const now = Date . now ( )
119+ const THREE_HOURS = 3 * 60 * 60 * 1000
126120
127- for ( const file_path of files ) {
121+ for ( const file_path of params . files ) {
128122 try {
129123 if ( ! fs . existsSync ( file_path ) ) continue
130124 const stats = fs . statSync ( file_path )
@@ -134,7 +128,7 @@ export class FilesCollector {
134128 const selection_timestamp =
135129 this . workspace_provider . get_selection_timestamp ( file_path ) ?? now
136130
137- if ( now - mtime < three_hours ) {
131+ if ( now - mtime < THREE_HOURS ) {
138132 recently_modified . push ( { path : file_path , mtime } )
139133 } else {
140134 older_files . push ( { path : file_path , timestamp : selection_timestamp } )
0 commit comments