mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-15 00:21:09 -07:00
complete
This commit is contained in:
@@ -1023,7 +1023,7 @@ describe('useTextBuffer', () => {
|
||||
useTextBuffer({ viewport, escapePastedPaths: true }),
|
||||
);
|
||||
act(() => result.current.insert(filePath, { paste: true }));
|
||||
expect(getBufferState(result).text).toBe(`@${filePath} `);
|
||||
expect(getBufferState(result).text).toBe(`@${escapePath(filePath)} `);
|
||||
});
|
||||
|
||||
it('should not prepend @ to an invalid file path on insert', () => {
|
||||
@@ -1042,7 +1042,7 @@ describe('useTextBuffer', () => {
|
||||
);
|
||||
const quotedPath = `'${filePath}'`;
|
||||
act(() => result.current.insert(quotedPath, { paste: true }));
|
||||
expect(getBufferState(result).text).toBe(`@${filePath} `);
|
||||
expect(getBufferState(result).text).toBe(`@${escapePath(filePath)} `);
|
||||
});
|
||||
|
||||
it('should not prepend @ to short text that is not a path', () => {
|
||||
@@ -1065,7 +1065,9 @@ describe('useTextBuffer', () => {
|
||||
);
|
||||
const filePaths = `${file1} ${file2}`;
|
||||
act(() => result.current.insert(filePaths, { paste: true }));
|
||||
expect(getBufferState(result).text).toBe(`@${file1} @${file2} `);
|
||||
expect(getBufferState(result).text).toBe(
|
||||
`@${escapePath(file1)} @${escapePath(file2)} `,
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle multiple paths with escaped spaces', () => {
|
||||
@@ -1083,7 +1085,7 @@ describe('useTextBuffer', () => {
|
||||
|
||||
act(() => result.current.insert(filePaths, { paste: true }));
|
||||
expect(getBufferState(result).text).toBe(
|
||||
`@${escapePath(file1)} @${file2} `,
|
||||
`@${escapePath(file1)} @${escapePath(file2)} `,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -285,6 +285,16 @@ describe('handleAtCommand', () => {
|
||||
});
|
||||
|
||||
it('should correctly unescape paths with escaped spaces', async () => {
|
||||
// Mock platform to linux so unescapePath handles backslash escapes
|
||||
vi.stubGlobal(
|
||||
'process',
|
||||
Object.create(process, {
|
||||
platform: {
|
||||
get: () => 'linux',
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const fileContent = 'This is the file content.';
|
||||
const filePath = await createTestFile(
|
||||
path.join(testRootDir, 'path', 'to', 'my file.txt'),
|
||||
@@ -955,6 +965,16 @@ describe('handleAtCommand', () => {
|
||||
});
|
||||
|
||||
it('should still handle escaped spaces in paths before punctuation', async () => {
|
||||
// Mock platform to linux so unescapePath handles backslash escapes
|
||||
vi.stubGlobal(
|
||||
'process',
|
||||
Object.create(process, {
|
||||
platform: {
|
||||
get: () => 'linux',
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const fileContent = 'Spaced file content';
|
||||
const filePath = await createTestFile(
|
||||
path.join(testRootDir, 'spaced file.txt'),
|
||||
|
||||
@@ -13,6 +13,7 @@ import type { Config, FileSearch } from '@google/gemini-cli-core';
|
||||
import {
|
||||
FileSearchFactory,
|
||||
FileDiscoveryService,
|
||||
escapePath,
|
||||
} from '@google/gemini-cli-core';
|
||||
import type { FileSystemStructure } from '@google/gemini-cli-test-utils';
|
||||
import { createTmpDir, cleanupTmpDir } from '@google/gemini-cli-test-utils';
|
||||
@@ -64,6 +65,7 @@ describe('useAtCompletion', () => {
|
||||
await cleanupTmpDir(testRootDir);
|
||||
}
|
||||
vi.restoreAllMocks();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
describe('File Search Logic', () => {
|
||||
@@ -90,7 +92,7 @@ describe('useAtCompletion', () => {
|
||||
'src/',
|
||||
'src/components/',
|
||||
'file.txt',
|
||||
'src/components/Button\\ with\\ spaces.tsx',
|
||||
escapePath('src/components/Button with spaces.tsx'),
|
||||
'src/components/Button.tsx',
|
||||
'src/index.js',
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user