@@ -21,6 +21,17 @@ const VOLATILE_ADE_FILES = new Set([
2121 ".ade/ade.sock" ,
2222 ".ade/local.secret.yaml" ,
2323] ) ;
24+ const ALWAYS_SKIPPED_DIRECTORY_NAMES = new Set ( [
25+ ".git" ,
26+ ".next" ,
27+ ".nuxt" ,
28+ ".svelte-kit" ,
29+ ".turbo" ,
30+ ".vite" ,
31+ "coverage" ,
32+ "dist" ,
33+ "node_modules" ,
34+ ] ) ;
2435
2536type IndexedFile = {
2637 path : string ;
@@ -41,6 +52,11 @@ type WorkspaceIndex = {
4152 builtAt : string | null ;
4253} ;
4354
55+ type IgnoreOptions = {
56+ shouldIgnore : ( relPath : string , includeIgnored : boolean ) => Promise < boolean > ;
57+ primeIgnoreCache ?: ( relPaths : string [ ] , includeIgnored : boolean ) => Promise < void > ;
58+ } ;
59+
4460function isVolatileAdeRuntimePath ( relPath : string ) : boolean {
4561 return VOLATILE_ADE_FILES . has ( relPath )
4662 || VOLATILE_ADE_PREFIXES . some ( ( prefix ) => relPath === prefix . slice ( 0 , - 1 ) || relPath . startsWith ( prefix ) ) ;
@@ -161,15 +177,9 @@ export function createFileSearchIndexService() {
161177 } ) ;
162178 } ;
163179
164- const shouldSkipDirectoryName = ( name : string ) : boolean => {
165- if ( name === ".git" ) return true ;
166- if ( name === "node_modules" ) return true ;
167- return false ;
168- } ;
180+ const shouldSkipDirectoryName = ( name : string ) : boolean => ALWAYS_SKIPPED_DIRECTORY_NAMES . has ( name ) ;
169181
170- const buildWorkspace = async ( index : WorkspaceIndex , opts : {
171- shouldIgnore : ( relPath : string , includeIgnored : boolean ) => Promise < boolean > ;
172- } ) : Promise < void > => {
182+ const buildWorkspace = async ( index : WorkspaceIndex , opts : IgnoreOptions ) : Promise < void > => {
173183 index . files . clear ( ) ;
174184 index . totalContentBytes = 0 ;
175185
@@ -187,8 +197,13 @@ export function createFileSearchIndexService() {
187197 continue ;
188198 }
189199
190- for ( const entry of entries ) {
191- const relPath = normalizeRelative ( path . join ( relDir , entry . name ) ) ;
200+ const candidates = entries
201+ . map ( ( entry ) => ( { entry, relPath : normalizeRelative ( path . join ( relDir , entry . name ) ) } ) )
202+ . filter ( ( candidate ) => Boolean ( candidate . relPath ) ) ;
203+
204+ await opts . primeIgnoreCache ?.( candidates . map ( ( candidate ) => candidate . relPath ) , index . includeIgnored ) ;
205+
206+ for ( const { entry, relPath } of candidates ) {
192207 if ( ! relPath ) continue ;
193208 if ( shouldSkipPathPrefix ( relPath , index . includeIgnored ) ) continue ;
194209 if ( entry . isDirectory ( ) && shouldSkipDirectoryName ( entry . name ) ) continue ;
@@ -215,9 +230,8 @@ export function createFileSearchIndexService() {
215230 index . builtAt = new Date ( ) . toISOString ( ) ;
216231 } ;
217232
218- const ensureBuilt = async ( workspaceId : string , rootPath : string , opts : {
233+ const ensureBuilt = async ( workspaceId : string , rootPath : string , opts : IgnoreOptions & {
219234 includeIgnored : boolean ;
220- shouldIgnore : ( relPath : string , includeIgnored : boolean ) => Promise < boolean > ;
221235 } ) : Promise < WorkspaceIndex > => {
222236 const index = getOrCreateWorkspaceIndex ( workspaceId , rootPath , opts . includeIgnored ) ;
223237 if ( index . files . size > 0 || index . builtAt ) return index ;
@@ -239,10 +253,12 @@ export function createFileSearchIndexService() {
239253 rootPath : string ;
240254 includeIgnored : boolean ;
241255 shouldIgnore : ( relPath : string , includeIgnored : boolean ) => Promise < boolean > ;
256+ primeIgnoreCache ?: ( relPaths : string [ ] , includeIgnored : boolean ) => Promise < void > ;
242257 } ) : Promise < void > {
243258 await ensureBuilt ( args . workspaceId , args . rootPath , {
244259 includeIgnored : args . includeIgnored ,
245- shouldIgnore : args . shouldIgnore
260+ shouldIgnore : args . shouldIgnore ,
261+ primeIgnoreCache : args . primeIgnoreCache
246262 } ) ;
247263 } ,
248264
@@ -253,10 +269,12 @@ export function createFileSearchIndexService() {
253269 limit : number ;
254270 includeIgnored : boolean ;
255271 shouldIgnore : ( relPath : string , includeIgnored : boolean ) => Promise < boolean > ;
272+ primeIgnoreCache ?: ( relPaths : string [ ] , includeIgnored : boolean ) => Promise < void > ;
256273 } ) : Promise < FilesQuickOpenItem [ ] > {
257274 const index = await ensureBuilt ( args . workspaceId , args . rootPath , {
258275 includeIgnored : args . includeIgnored ,
259- shouldIgnore : args . shouldIgnore
276+ shouldIgnore : args . shouldIgnore ,
277+ primeIgnoreCache : args . primeIgnoreCache
260278 } ) ;
261279
262280 const scored : FilesQuickOpenItem [ ] = [ ] ;
@@ -276,10 +294,12 @@ export function createFileSearchIndexService() {
276294 limit : number ;
277295 includeIgnored : boolean ;
278296 shouldIgnore : ( relPath : string , includeIgnored : boolean ) => Promise < boolean > ;
297+ primeIgnoreCache ?: ( relPaths : string [ ] , includeIgnored : boolean ) => Promise < void > ;
279298 } ) : Promise < FilesSearchTextMatch [ ] > {
280299 const index = await ensureBuilt ( args . workspaceId , args . rootPath , {
281300 includeIgnored : args . includeIgnored ,
282- shouldIgnore : args . shouldIgnore
301+ shouldIgnore : args . shouldIgnore ,
302+ primeIgnoreCache : args . primeIgnoreCache
283303 } ) ;
284304
285305 const out : FilesSearchTextMatch [ ] = [ ] ;
0 commit comments