@@ -387,4 +387,45 @@ export interface TestInterface {
387387 expect ( stdout ) . toContain ( 'Global limit of 250 results reached' )
388388 }
389389 } )
390+
391+ test ( 'handles glob pattern flags correctly without regex parse errors' , async ( ) => {
392+ // Create test files with different extensions
393+ await fs . promises . writeFile (
394+ path . join ( testDataDir , 'typescript-file.ts' ) ,
395+ `export const GLOB_TEST_TS = 'typescript file';` ,
396+ )
397+
398+ await fs . promises . writeFile (
399+ path . join ( testDataDir , 'javascript-file.js' ) ,
400+ `export const GLOB_TEST_JS = 'javascript file';` ,
401+ )
402+
403+ await fs . promises . writeFile (
404+ path . join ( testDataDir , 'text-file.txt' ) ,
405+ `GLOB_TEST_TXT in text file` ,
406+ )
407+
408+ // Search with glob flags to only match .ts and .tsx files
409+ const parameters = {
410+ pattern : 'GLOB_TEST' ,
411+ flags : '-g *.ts -g *.tsx' ,
412+ cwd : 'src/__tests__/data' ,
413+ maxResults : 30 ,
414+ }
415+
416+ const result = await handleCodeSearch ( parameters , 'test-id' )
417+
418+ // Should not have a stderr with regex parse error
419+ expect ( ( result [ 0 ] . value as any ) . stderr ) . toBeUndefined ( )
420+
421+ const stdout = ( result [ 0 ] . value as any ) . stdout
422+
423+ // Should find the .ts file
424+ expect ( stdout ) . toContain ( 'typescript-file.ts' )
425+ expect ( stdout ) . toContain ( 'GLOB_TEST_TS' )
426+
427+ // Should not find the .js or .txt files
428+ expect ( stdout ) . not . toContain ( 'javascript-file.js' )
429+ expect ( stdout ) . not . toContain ( 'text-file.txt' )
430+ } )
390431} )
0 commit comments