summaryrefslogtreecommitdiff
path: root/packages/core/src/utils/filesearch/fileSearch.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/core/src/utils/filesearch/fileSearch.test.ts')
-rw-r--r--packages/core/src/utils/filesearch/fileSearch.test.ts29
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/core/src/utils/filesearch/fileSearch.test.ts b/packages/core/src/utils/filesearch/fileSearch.test.ts
index 2deea82d..316f17ec 100644
--- a/packages/core/src/utils/filesearch/fileSearch.test.ts
+++ b/packages/core/src/utils/filesearch/fileSearch.test.ts
@@ -566,6 +566,35 @@ describe('FileSearch', () => {
expect(limitedResults).toEqual(['file1.js', 'file2.js']);
});
+ it('should handle file paths with special characters that need escaping', async () => {
+ tmpDir = await createTmpDir({
+ src: {
+ 'file with (special) chars.txt': '',
+ 'another-file.txt': '',
+ },
+ });
+
+ const fileSearch = FileSearchFactory.create({
+ projectRoot: tmpDir,
+ useGitignore: false,
+ useGeminiignore: false,
+ ignoreDirs: [],
+ cache: false,
+ cacheTtl: 0,
+ enableRecursiveFileSearch: true,
+ });
+
+ await fileSearch.initialize();
+
+ // Search for the file using a pattern that contains special characters.
+ // The `unescapePath` function should handle the escaped path correctly.
+ const results = await fileSearch.search(
+ 'src/file with \\(special\\) chars.txt',
+ );
+
+ expect(results).toEqual(['src/file with (special) chars.txt']);
+ });
+
describe('DirectoryFileSearch', () => {
it('should search for files in the current directory', async () => {
tmpDir = await createTmpDir({