diff options
| author | Sandy Tao <[email protected]> | 2025-08-04 13:35:26 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-04 20:35:26 +0000 |
| commit | 8da6d23688646dde2011fc3577faea1093077a3e (patch) | |
| tree | c37ebbd0c96bdf146a8dd9b35a4c46386d7cf09e /packages/cli/src/ui/hooks | |
| parent | 37b83e05a71690d4d8f72f6bddb63435c31a5a01 (diff) | |
refactor(core): Rename useSlashCompletion to useCommandCompletion (#5532)
Diffstat (limited to 'packages/cli/src/ui/hooks')
| -rw-r--r-- | packages/cli/src/ui/hooks/useCommandCompletion.test.ts (renamed from packages/cli/src/ui/hooks/useSlashCompletion.test.ts) | 96 | ||||
| -rw-r--r-- | packages/cli/src/ui/hooks/useCommandCompletion.tsx (renamed from packages/cli/src/ui/hooks/useSlashCompletion.tsx) | 6 |
2 files changed, 51 insertions, 51 deletions
diff --git a/packages/cli/src/ui/hooks/useSlashCompletion.test.ts b/packages/cli/src/ui/hooks/useCommandCompletion.test.ts index da4dc87b..005b4e7d 100644 --- a/packages/cli/src/ui/hooks/useSlashCompletion.test.ts +++ b/packages/cli/src/ui/hooks/useCommandCompletion.test.ts @@ -8,7 +8,7 @@ import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest'; import { renderHook, act, waitFor } from '@testing-library/react'; -import { useSlashCompletion } from './useSlashCompletion.js'; +import { useCommandCompletion } from './useCommandCompletion.js'; import * as fs from 'fs/promises'; import * as path from 'path'; import * as os from 'os'; @@ -16,7 +16,7 @@ import { CommandContext, SlashCommand } from '../commands/types.js'; import { Config, FileDiscoveryService } from '@google/gemini-cli-core'; import { useTextBuffer } from '../components/shared/text-buffer.js'; -describe('useSlashCompletion', () => { +describe('useCommandCompletion', () => { let testRootDir: string; let mockConfig: Config; @@ -82,7 +82,7 @@ describe('useSlashCompletion', () => { { name: 'dummy', description: 'dummy' }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest(''), testDirs, testRootDir, @@ -113,7 +113,7 @@ describe('useSlashCompletion', () => { const { result, rerender } = renderHook( ({ text }) => { const textBuffer = useTextBufferForTest(text); - return useSlashCompletion( + return useCommandCompletion( textBuffer, testDirs, testRootDir, @@ -145,7 +145,7 @@ describe('useSlashCompletion', () => { ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/help'), testDirs, testRootDir, @@ -184,7 +184,7 @@ describe('useSlashCompletion', () => { { name: 'dummy', description: 'dummy' }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest(''), testDirs, testRootDir, @@ -207,7 +207,7 @@ describe('useSlashCompletion', () => { { name: 'dummy', description: 'dummy' }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest(''), testDirs, testRootDir, @@ -234,7 +234,7 @@ describe('useSlashCompletion', () => { }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/h'), testDirs, testRootDir, @@ -264,7 +264,7 @@ describe('useSlashCompletion', () => { }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/h'), testDirs, testRootDir, @@ -295,7 +295,7 @@ describe('useSlashCompletion', () => { { name: 'chat', description: 'Manage chat' }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/'), testDirs, testRootDir, @@ -343,7 +343,7 @@ describe('useSlashCompletion', () => { })) as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/command'), testDirs, testRootDir, @@ -403,7 +403,7 @@ describe('useSlashCompletion', () => { }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/'), testDirs, testRootDir, @@ -426,7 +426,7 @@ describe('useSlashCompletion', () => { }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/mem'), testDirs, testRootDir, @@ -450,7 +450,7 @@ describe('useSlashCompletion', () => { }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/usag'), // part of the word "usage" testDirs, testRootDir, @@ -477,7 +477,7 @@ describe('useSlashCompletion', () => { }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/clear'), // No trailing space testDirs, testRootDir, @@ -509,7 +509,7 @@ describe('useSlashCompletion', () => { ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest(query), testDirs, testRootDir, @@ -530,7 +530,7 @@ describe('useSlashCompletion', () => { }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/clear '), testDirs, testRootDir, @@ -551,7 +551,7 @@ describe('useSlashCompletion', () => { }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/unknown-command'), testDirs, testRootDir, @@ -585,7 +585,7 @@ describe('useSlashCompletion', () => { ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/memory'), // Note: no trailing space testDirs, testRootDir, @@ -623,7 +623,7 @@ describe('useSlashCompletion', () => { }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/memory'), testDirs, testRootDir, @@ -659,7 +659,7 @@ describe('useSlashCompletion', () => { }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/memory a'), testDirs, testRootDir, @@ -691,7 +691,7 @@ describe('useSlashCompletion', () => { }, ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/memory dothisnow'), testDirs, testRootDir, @@ -734,7 +734,7 @@ describe('useSlashCompletion', () => { ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/chat resume my-ch'), testDirs, testRootDir, @@ -778,7 +778,7 @@ describe('useSlashCompletion', () => { ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/chat resume '), testDirs, testRootDir, @@ -813,7 +813,7 @@ describe('useSlashCompletion', () => { ] as unknown as SlashCommand[]; const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('/chat resume '), testDirs, testRootDir, @@ -843,7 +843,7 @@ describe('useSlashCompletion', () => { await createTestFile('', 'README.md'); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@s'), testDirs, testRootDir, @@ -879,7 +879,7 @@ describe('useSlashCompletion', () => { await createTestFile('', 'src', 'index.ts'); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@src/comp'), testDirs, testRootDir, @@ -907,7 +907,7 @@ describe('useSlashCompletion', () => { await createTestFile('', 'src', 'index.ts'); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@.'), testDirs, testRootDir, @@ -941,7 +941,7 @@ describe('useSlashCompletion', () => { await createEmptyDir('dist'); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@d'), testDirs, testRootDir, @@ -969,7 +969,7 @@ describe('useSlashCompletion', () => { await createTestFile('', 'README.md'); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@'), testDirs, testRootDir, @@ -1004,7 +1004,7 @@ describe('useSlashCompletion', () => { .mockImplementation(() => {}); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@'), testDirs, testRootDir, @@ -1037,7 +1037,7 @@ describe('useSlashCompletion', () => { await createEmptyDir('data'); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@d'), testDirs, testRootDir, @@ -1073,7 +1073,7 @@ describe('useSlashCompletion', () => { await createTestFile('', 'README.md'); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@'), testDirs, testRootDir, @@ -1108,7 +1108,7 @@ describe('useSlashCompletion', () => { await createTestFile('', 'temp', 'temp.log'); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@t'), testDirs, testRootDir, @@ -1153,7 +1153,7 @@ describe('useSlashCompletion', () => { const { result } = renderHook(() => { const textBuffer = useTextBufferForTest('/mem'); - const completion = useSlashCompletion( + const completion = useCommandCompletion( textBuffer, testDirs, testRootDir, @@ -1197,7 +1197,7 @@ describe('useSlashCompletion', () => { const { result } = renderHook(() => { const textBuffer = useTextBufferForTest('/memory'); - const completion = useSlashCompletion( + const completion = useCommandCompletion( textBuffer, testDirs, testRootDir, @@ -1243,7 +1243,7 @@ describe('useSlashCompletion', () => { const { result } = renderHook(() => { const textBuffer = useTextBufferForTest('/?'); - const completion = useSlashCompletion( + const completion = useCommandCompletion( textBuffer, testDirs, testRootDir, @@ -1272,7 +1272,7 @@ describe('useSlashCompletion', () => { it('should complete a file path', () => { const { result } = renderHook(() => { const textBuffer = useTextBufferForTest('@src/fi'); - const completion = useSlashCompletion( + const completion = useCommandCompletion( textBuffer, testDirs, testRootDir, @@ -1302,7 +1302,7 @@ describe('useSlashCompletion', () => { const { result } = renderHook(() => { const textBuffer = useTextBufferForTest(text, cursorOffset); - const completion = useSlashCompletion( + const completion = useCommandCompletion( textBuffer, testDirs, testRootDir, @@ -1331,7 +1331,7 @@ describe('useSlashCompletion', () => { const { result } = renderHook(() => { const textBuffer = useTextBufferForTest(text); - const completion = useSlashCompletion( + const completion = useCommandCompletion( textBuffer, testDirs, testRootDir, @@ -1363,7 +1363,7 @@ describe('useSlashCompletion', () => { await createTestFile('', 'backup[old].txt'); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@my'), testDirs, testRootDir, @@ -1390,7 +1390,7 @@ describe('useSlashCompletion', () => { await createTestFile('', 'script(v2).sh'); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@doc'), testDirs, testRootDir, @@ -1417,7 +1417,7 @@ describe('useSlashCompletion', () => { await createTestFile('', 'config[dev].json'); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@backup'), testDirs, testRootDir, @@ -1444,7 +1444,7 @@ describe('useSlashCompletion', () => { await createTestFile('', 'data & config {prod}.json'); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@my'), testDirs, testRootDir, @@ -1477,7 +1477,7 @@ describe('useSlashCompletion', () => { ); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@projects/my'), testDirs, testRootDir, @@ -1512,7 +1512,7 @@ describe('useSlashCompletion', () => { ); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@deep/nested/special'), testDirs, testRootDir, @@ -1542,7 +1542,7 @@ describe('useSlashCompletion', () => { await createEmptyDir('data & logs'); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@'), testDirs, testRootDir, @@ -1583,7 +1583,7 @@ describe('useSlashCompletion', () => { await createTestFile('', 'important!.md'); const { result } = renderHook(() => - useSlashCompletion( + useCommandCompletion( useTextBufferForTest('@'), testDirs, testRootDir, diff --git a/packages/cli/src/ui/hooks/useSlashCompletion.tsx b/packages/cli/src/ui/hooks/useCommandCompletion.tsx index 3b59bd45..9227be39 100644 --- a/packages/cli/src/ui/hooks/useSlashCompletion.tsx +++ b/packages/cli/src/ui/hooks/useCommandCompletion.tsx @@ -28,7 +28,7 @@ import { isSlashCommand } from '../utils/commandUtils.js'; import { toCodePoints } from '../utils/textUtils.js'; import { useCompletion } from './useCompletion.js'; -export interface UseSlashCompletionReturn { +export interface UseCommandCompletionReturn { suggestions: Suggestion[]; activeSuggestionIndex: number; visibleStartIndex: number; @@ -43,7 +43,7 @@ export interface UseSlashCompletionReturn { handleAutocomplete: (indexToUse: number) => void; } -export function useSlashCompletion( +export function useCommandCompletion( buffer: TextBuffer, dirs: readonly string[], cwd: string, @@ -51,7 +51,7 @@ export function useSlashCompletion( commandContext: CommandContext, reverseSearchActive: boolean = false, config?: Config, -): UseSlashCompletionReturn { +): UseCommandCompletionReturn { const { suggestions, activeSuggestionIndex, |
