mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
feat: Do not add trailing space on directory autocomplete (#11227)
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
3acb014ed7
commit
60420e52db
@@ -515,6 +515,68 @@ describe('useCommandCompletion', () => {
|
|||||||
'@src/file1.txt is a good file',
|
'@src/file1.txt is a good file',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should complete a directory path ending with / without a trailing space', async () => {
|
||||||
|
setupMocks({
|
||||||
|
atSuggestions: [{ label: 'src/components/', value: 'src/components/' }],
|
||||||
|
});
|
||||||
|
|
||||||
|
const { result } = renderHook(() => {
|
||||||
|
const textBuffer = useTextBufferForTest('@src/comp');
|
||||||
|
const completion = useCommandCompletion(
|
||||||
|
textBuffer,
|
||||||
|
testDirs,
|
||||||
|
testRootDir,
|
||||||
|
[],
|
||||||
|
mockCommandContext,
|
||||||
|
false,
|
||||||
|
mockConfig,
|
||||||
|
);
|
||||||
|
return { ...completion, textBuffer };
|
||||||
|
});
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(result.current.suggestions.length).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
act(() => {
|
||||||
|
result.current.handleAutocomplete(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.current.textBuffer.text).toBe('@src/components/');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should complete a directory path ending with \\ without a trailing space', async () => {
|
||||||
|
setupMocks({
|
||||||
|
atSuggestions: [
|
||||||
|
{ label: 'src\\components\\', value: 'src\\components\\' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const { result } = renderHook(() => {
|
||||||
|
const textBuffer = useTextBufferForTest('@src\\comp');
|
||||||
|
const completion = useCommandCompletion(
|
||||||
|
textBuffer,
|
||||||
|
testDirs,
|
||||||
|
testRootDir,
|
||||||
|
[],
|
||||||
|
mockCommandContext,
|
||||||
|
false,
|
||||||
|
mockConfig,
|
||||||
|
);
|
||||||
|
return { ...completion, textBuffer };
|
||||||
|
});
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(result.current.suggestions.length).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
act(() => {
|
||||||
|
result.current.handleAutocomplete(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.current.textBuffer.text).toBe('@src\\components\\');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('prompt completion filtering', () => {
|
describe('prompt completion filtering', () => {
|
||||||
|
|||||||
@@ -230,7 +230,11 @@ export function useCommandCompletion(
|
|||||||
|
|
||||||
const lineCodePoints = toCodePoints(buffer.lines[cursorRow] || '');
|
const lineCodePoints = toCodePoints(buffer.lines[cursorRow] || '');
|
||||||
const charAfterCompletion = lineCodePoints[end];
|
const charAfterCompletion = lineCodePoints[end];
|
||||||
if (charAfterCompletion !== ' ') {
|
if (
|
||||||
|
charAfterCompletion !== ' ' &&
|
||||||
|
!suggestionText.endsWith('/') &&
|
||||||
|
!suggestionText.endsWith('\\')
|
||||||
|
) {
|
||||||
suggestionText += ' ';
|
suggestionText += ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user