refactor(core): Rename useSlashCompletion to useCommandCompletion (#5532)

This commit is contained in:
Sandy Tao 2025-08-04 13:35:26 -07:00 committed by GitHub
parent 37b83e05a7
commit 8da6d23688
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 141 additions and 141 deletions

View File

@ -20,9 +20,9 @@ import {
UseShellHistoryReturn, UseShellHistoryReturn,
} from '../hooks/useShellHistory.js'; } from '../hooks/useShellHistory.js';
import { import {
useSlashCompletion, useCommandCompletion,
UseSlashCompletionReturn, UseCommandCompletionReturn,
} from '../hooks/useSlashCompletion.js'; } from '../hooks/useCommandCompletion.js';
import { import {
useInputHistory, useInputHistory,
UseInputHistoryReturn, UseInputHistoryReturn,
@ -31,7 +31,7 @@ import * as clipboardUtils from '../utils/clipboardUtils.js';
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js'; import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
vi.mock('../hooks/useShellHistory.js'); vi.mock('../hooks/useShellHistory.js');
vi.mock('../hooks/useSlashCompletion.js'); vi.mock('../hooks/useCommandCompletion.js');
vi.mock('../hooks/useInputHistory.js'); vi.mock('../hooks/useInputHistory.js');
vi.mock('../utils/clipboardUtils.js'); vi.mock('../utils/clipboardUtils.js');
@ -86,13 +86,13 @@ const mockSlashCommands: SlashCommand[] = [
describe('InputPrompt', () => { describe('InputPrompt', () => {
let props: InputPromptProps; let props: InputPromptProps;
let mockShellHistory: UseShellHistoryReturn; let mockShellHistory: UseShellHistoryReturn;
let mockSlashCompletion: UseSlashCompletionReturn; let mockCommandCompletion: UseCommandCompletionReturn;
let mockInputHistory: UseInputHistoryReturn; let mockInputHistory: UseInputHistoryReturn;
let mockBuffer: TextBuffer; let mockBuffer: TextBuffer;
let mockCommandContext: CommandContext; let mockCommandContext: CommandContext;
const mockedUseShellHistory = vi.mocked(useShellHistory); const mockedUseShellHistory = vi.mocked(useShellHistory);
const mockedUseSlashCompletion = vi.mocked(useSlashCompletion); const mockedUseCommandCompletion = vi.mocked(useCommandCompletion);
const mockedUseInputHistory = vi.mocked(useInputHistory); const mockedUseInputHistory = vi.mocked(useInputHistory);
beforeEach(() => { beforeEach(() => {
@ -146,7 +146,7 @@ describe('InputPrompt', () => {
}; };
mockedUseShellHistory.mockReturnValue(mockShellHistory); mockedUseShellHistory.mockReturnValue(mockShellHistory);
mockSlashCompletion = { mockCommandCompletion = {
suggestions: [], suggestions: [],
activeSuggestionIndex: -1, activeSuggestionIndex: -1,
isLoadingSuggestions: false, isLoadingSuggestions: false,
@ -160,7 +160,7 @@ describe('InputPrompt', () => {
setShowSuggestions: vi.fn(), setShowSuggestions: vi.fn(),
handleAutocomplete: vi.fn(), handleAutocomplete: vi.fn(),
}; };
mockedUseSlashCompletion.mockReturnValue(mockSlashCompletion); mockedUseCommandCompletion.mockReturnValue(mockCommandCompletion);
mockInputHistory = { mockInputHistory = {
navigateUp: vi.fn(), navigateUp: vi.fn(),
@ -271,8 +271,8 @@ describe('InputPrompt', () => {
}); });
it('should call completion.navigateUp for both up arrow and Ctrl+P when suggestions are showing', async () => { it('should call completion.navigateUp for both up arrow and Ctrl+P when suggestions are showing', async () => {
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [ suggestions: [
{ label: 'memory', value: 'memory' }, { label: 'memory', value: 'memory' },
@ -291,15 +291,15 @@ describe('InputPrompt', () => {
stdin.write('\u0010'); // Ctrl+P stdin.write('\u0010'); // Ctrl+P
await wait(); await wait();
expect(mockSlashCompletion.navigateUp).toHaveBeenCalledTimes(2); expect(mockCommandCompletion.navigateUp).toHaveBeenCalledTimes(2);
expect(mockSlashCompletion.navigateDown).not.toHaveBeenCalled(); expect(mockCommandCompletion.navigateDown).not.toHaveBeenCalled();
unmount(); unmount();
}); });
it('should call completion.navigateDown for both down arrow and Ctrl+N when suggestions are showing', async () => { it('should call completion.navigateDown for both down arrow and Ctrl+N when suggestions are showing', async () => {
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [ suggestions: [
{ label: 'memory', value: 'memory' }, { label: 'memory', value: 'memory' },
@ -317,15 +317,15 @@ describe('InputPrompt', () => {
stdin.write('\u000E'); // Ctrl+N stdin.write('\u000E'); // Ctrl+N
await wait(); await wait();
expect(mockSlashCompletion.navigateDown).toHaveBeenCalledTimes(2); expect(mockCommandCompletion.navigateDown).toHaveBeenCalledTimes(2);
expect(mockSlashCompletion.navigateUp).not.toHaveBeenCalled(); expect(mockCommandCompletion.navigateUp).not.toHaveBeenCalled();
unmount(); unmount();
}); });
it('should NOT call completion navigation when suggestions are not showing', async () => { it('should NOT call completion navigation when suggestions are not showing', async () => {
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: false, showSuggestions: false,
}); });
props.buffer.setText('some text'); props.buffer.setText('some text');
@ -342,8 +342,8 @@ describe('InputPrompt', () => {
stdin.write('\u000E'); // Ctrl+N stdin.write('\u000E'); // Ctrl+N
await wait(); await wait();
expect(mockSlashCompletion.navigateUp).not.toHaveBeenCalled(); expect(mockCommandCompletion.navigateUp).not.toHaveBeenCalled();
expect(mockSlashCompletion.navigateDown).not.toHaveBeenCalled(); expect(mockCommandCompletion.navigateDown).not.toHaveBeenCalled();
unmount(); unmount();
}); });
@ -472,8 +472,8 @@ describe('InputPrompt', () => {
it('should complete a partial parent command', async () => { it('should complete a partial parent command', async () => {
// SCENARIO: /mem -> Tab // SCENARIO: /mem -> Tab
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [{ label: 'memory', value: 'memory', description: '...' }], suggestions: [{ label: 'memory', value: 'memory', description: '...' }],
activeSuggestionIndex: 0, activeSuggestionIndex: 0,
@ -486,14 +486,14 @@ describe('InputPrompt', () => {
stdin.write('\t'); // Press Tab stdin.write('\t'); // Press Tab
await wait(); await wait();
expect(mockSlashCompletion.handleAutocomplete).toHaveBeenCalledWith(0); expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(0);
unmount(); unmount();
}); });
it('should append a sub-command when the parent command is already complete', async () => { it('should append a sub-command when the parent command is already complete', async () => {
// SCENARIO: /memory -> Tab (to accept 'add') // SCENARIO: /memory -> Tab (to accept 'add')
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [ suggestions: [
{ label: 'show', value: 'show' }, { label: 'show', value: 'show' },
@ -509,14 +509,14 @@ describe('InputPrompt', () => {
stdin.write('\t'); // Press Tab stdin.write('\t'); // Press Tab
await wait(); await wait();
expect(mockSlashCompletion.handleAutocomplete).toHaveBeenCalledWith(1); expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(1);
unmount(); unmount();
}); });
it('should handle the "backspace" edge case correctly', async () => { it('should handle the "backspace" edge case correctly', async () => {
// SCENARIO: /memory -> Backspace -> /memory -> Tab (to accept 'show') // SCENARIO: /memory -> Backspace -> /memory -> Tab (to accept 'show')
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [ suggestions: [
{ label: 'show', value: 'show' }, { label: 'show', value: 'show' },
@ -534,14 +534,14 @@ describe('InputPrompt', () => {
await wait(); await wait();
// It should NOT become '/show'. It should correctly become '/memory show'. // It should NOT become '/show'. It should correctly become '/memory show'.
expect(mockSlashCompletion.handleAutocomplete).toHaveBeenCalledWith(0); expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(0);
unmount(); unmount();
}); });
it('should complete a partial argument for a command', async () => { it('should complete a partial argument for a command', async () => {
// SCENARIO: /chat resume fi- -> Tab // SCENARIO: /chat resume fi- -> Tab
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [{ label: 'fix-foo', value: 'fix-foo' }], suggestions: [{ label: 'fix-foo', value: 'fix-foo' }],
activeSuggestionIndex: 0, activeSuggestionIndex: 0,
@ -554,13 +554,13 @@ describe('InputPrompt', () => {
stdin.write('\t'); // Press Tab stdin.write('\t'); // Press Tab
await wait(); await wait();
expect(mockSlashCompletion.handleAutocomplete).toHaveBeenCalledWith(0); expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(0);
unmount(); unmount();
}); });
it('should autocomplete on Enter when suggestions are active, without submitting', async () => { it('should autocomplete on Enter when suggestions are active, without submitting', async () => {
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [{ label: 'memory', value: 'memory' }], suggestions: [{ label: 'memory', value: 'memory' }],
activeSuggestionIndex: 0, activeSuggestionIndex: 0,
@ -574,7 +574,7 @@ describe('InputPrompt', () => {
await wait(); await wait();
// The app should autocomplete the text, NOT submit. // The app should autocomplete the text, NOT submit.
expect(mockSlashCompletion.handleAutocomplete).toHaveBeenCalledWith(0); expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(0);
expect(props.onSubmit).not.toHaveBeenCalled(); expect(props.onSubmit).not.toHaveBeenCalled();
unmount(); unmount();
@ -590,8 +590,8 @@ describe('InputPrompt', () => {
}, },
]; ];
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [{ label: 'help', value: 'help' }], suggestions: [{ label: 'help', value: 'help' }],
activeSuggestionIndex: 0, activeSuggestionIndex: 0,
@ -604,7 +604,7 @@ describe('InputPrompt', () => {
stdin.write('\t'); // Press Tab for autocomplete stdin.write('\t'); // Press Tab for autocomplete
await wait(); await wait();
expect(mockSlashCompletion.handleAutocomplete).toHaveBeenCalledWith(0); expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(0);
unmount(); unmount();
}); });
@ -622,8 +622,8 @@ describe('InputPrompt', () => {
}); });
it('should submit directly on Enter when isPerfectMatch is true', async () => { it('should submit directly on Enter when isPerfectMatch is true', async () => {
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: false, showSuggestions: false,
isPerfectMatch: true, isPerfectMatch: true,
}); });
@ -640,8 +640,8 @@ describe('InputPrompt', () => {
}); });
it('should submit directly on Enter when a complete leaf command is typed', async () => { it('should submit directly on Enter when a complete leaf command is typed', async () => {
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: false, showSuggestions: false,
isPerfectMatch: false, // Added explicit isPerfectMatch false isPerfectMatch: false, // Added explicit isPerfectMatch false
}); });
@ -658,8 +658,8 @@ describe('InputPrompt', () => {
}); });
it('should autocomplete an @-path on Enter without submitting', async () => { it('should autocomplete an @-path on Enter without submitting', async () => {
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [{ label: 'index.ts', value: 'index.ts' }], suggestions: [{ label: 'index.ts', value: 'index.ts' }],
activeSuggestionIndex: 0, activeSuggestionIndex: 0,
@ -672,7 +672,7 @@ describe('InputPrompt', () => {
stdin.write('\r'); stdin.write('\r');
await wait(); await wait();
expect(mockSlashCompletion.handleAutocomplete).toHaveBeenCalledWith(0); expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(0);
expect(props.onSubmit).not.toHaveBeenCalled(); expect(props.onSubmit).not.toHaveBeenCalled();
unmount(); unmount();
}); });
@ -704,7 +704,7 @@ describe('InputPrompt', () => {
await wait(); await wait();
expect(props.buffer.setText).toHaveBeenCalledWith(''); expect(props.buffer.setText).toHaveBeenCalledWith('');
expect(mockSlashCompletion.resetCompletionState).toHaveBeenCalled(); expect(mockCommandCompletion.resetCompletionState).toHaveBeenCalled();
expect(props.onSubmit).not.toHaveBeenCalled(); expect(props.onSubmit).not.toHaveBeenCalled();
unmount(); unmount();
}); });
@ -728,8 +728,8 @@ describe('InputPrompt', () => {
mockBuffer.lines = ['@src/components']; mockBuffer.lines = ['@src/components'];
mockBuffer.cursor = [0, 15]; mockBuffer.cursor = [0, 15];
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [{ label: 'Button.tsx', value: 'Button.tsx' }], suggestions: [{ label: 'Button.tsx', value: 'Button.tsx' }],
}); });
@ -738,7 +738,7 @@ describe('InputPrompt', () => {
await wait(); await wait();
// Verify useCompletion was called with correct signature // Verify useCompletion was called with correct signature
expect(mockedUseSlashCompletion).toHaveBeenCalledWith( expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
mockBuffer, mockBuffer,
['/test/project/src'], ['/test/project/src'],
path.join('test', 'project', 'src'), path.join('test', 'project', 'src'),
@ -756,8 +756,8 @@ describe('InputPrompt', () => {
mockBuffer.lines = ['/memory']; mockBuffer.lines = ['/memory'];
mockBuffer.cursor = [0, 7]; mockBuffer.cursor = [0, 7];
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [{ label: 'show', value: 'show' }], suggestions: [{ label: 'show', value: 'show' }],
}); });
@ -765,7 +765,7 @@ describe('InputPrompt', () => {
const { unmount } = render(<InputPrompt {...props} />); const { unmount } = render(<InputPrompt {...props} />);
await wait(); await wait();
expect(mockedUseSlashCompletion).toHaveBeenCalledWith( expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
mockBuffer, mockBuffer,
['/test/project/src'], ['/test/project/src'],
path.join('test', 'project', 'src'), path.join('test', 'project', 'src'),
@ -783,8 +783,8 @@ describe('InputPrompt', () => {
mockBuffer.lines = ['@src/file.ts hello']; mockBuffer.lines = ['@src/file.ts hello'];
mockBuffer.cursor = [0, 18]; mockBuffer.cursor = [0, 18];
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: false, showSuggestions: false,
suggestions: [], suggestions: [],
}); });
@ -792,7 +792,7 @@ describe('InputPrompt', () => {
const { unmount } = render(<InputPrompt {...props} />); const { unmount } = render(<InputPrompt {...props} />);
await wait(); await wait();
expect(mockedUseSlashCompletion).toHaveBeenCalledWith( expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
mockBuffer, mockBuffer,
['/test/project/src'], ['/test/project/src'],
path.join('test', 'project', 'src'), path.join('test', 'project', 'src'),
@ -810,8 +810,8 @@ describe('InputPrompt', () => {
mockBuffer.lines = ['/memory add']; mockBuffer.lines = ['/memory add'];
mockBuffer.cursor = [0, 11]; mockBuffer.cursor = [0, 11];
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: false, showSuggestions: false,
suggestions: [], suggestions: [],
}); });
@ -819,7 +819,7 @@ describe('InputPrompt', () => {
const { unmount } = render(<InputPrompt {...props} />); const { unmount } = render(<InputPrompt {...props} />);
await wait(); await wait();
expect(mockedUseSlashCompletion).toHaveBeenCalledWith( expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
mockBuffer, mockBuffer,
['/test/project/src'], ['/test/project/src'],
path.join('test', 'project', 'src'), path.join('test', 'project', 'src'),
@ -837,8 +837,8 @@ describe('InputPrompt', () => {
mockBuffer.lines = ['hello world']; mockBuffer.lines = ['hello world'];
mockBuffer.cursor = [0, 5]; mockBuffer.cursor = [0, 5];
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: false, showSuggestions: false,
suggestions: [], suggestions: [],
}); });
@ -846,7 +846,7 @@ describe('InputPrompt', () => {
const { unmount } = render(<InputPrompt {...props} />); const { unmount } = render(<InputPrompt {...props} />);
await wait(); await wait();
expect(mockedUseSlashCompletion).toHaveBeenCalledWith( expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
mockBuffer, mockBuffer,
['/test/project/src'], ['/test/project/src'],
path.join('test', 'project', 'src'), path.join('test', 'project', 'src'),
@ -864,8 +864,8 @@ describe('InputPrompt', () => {
mockBuffer.lines = ['first line', '/memory']; mockBuffer.lines = ['first line', '/memory'];
mockBuffer.cursor = [1, 7]; mockBuffer.cursor = [1, 7];
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: false, showSuggestions: false,
suggestions: [], suggestions: [],
}); });
@ -874,7 +874,7 @@ describe('InputPrompt', () => {
await wait(); await wait();
// Verify useCompletion was called with the buffer // Verify useCompletion was called with the buffer
expect(mockedUseSlashCompletion).toHaveBeenCalledWith( expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
mockBuffer, mockBuffer,
['/test/project/src'], ['/test/project/src'],
path.join('test', 'project', 'src'), path.join('test', 'project', 'src'),
@ -892,8 +892,8 @@ describe('InputPrompt', () => {
mockBuffer.lines = ['/memory']; mockBuffer.lines = ['/memory'];
mockBuffer.cursor = [0, 7]; mockBuffer.cursor = [0, 7];
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [{ label: 'show', value: 'show' }], suggestions: [{ label: 'show', value: 'show' }],
}); });
@ -901,7 +901,7 @@ describe('InputPrompt', () => {
const { unmount } = render(<InputPrompt {...props} />); const { unmount } = render(<InputPrompt {...props} />);
await wait(); await wait();
expect(mockedUseSlashCompletion).toHaveBeenCalledWith( expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
mockBuffer, mockBuffer,
['/test/project/src'], ['/test/project/src'],
path.join('test', 'project', 'src'), path.join('test', 'project', 'src'),
@ -920,8 +920,8 @@ describe('InputPrompt', () => {
mockBuffer.lines = ['@src/file👍.txt']; mockBuffer.lines = ['@src/file👍.txt'];
mockBuffer.cursor = [0, 14]; // After the emoji character mockBuffer.cursor = [0, 14]; // After the emoji character
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [{ label: 'file👍.txt', value: 'file👍.txt' }], suggestions: [{ label: 'file👍.txt', value: 'file👍.txt' }],
}); });
@ -929,7 +929,7 @@ describe('InputPrompt', () => {
const { unmount } = render(<InputPrompt {...props} />); const { unmount } = render(<InputPrompt {...props} />);
await wait(); await wait();
expect(mockedUseSlashCompletion).toHaveBeenCalledWith( expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
mockBuffer, mockBuffer,
['/test/project/src'], ['/test/project/src'],
path.join('test', 'project', 'src'), path.join('test', 'project', 'src'),
@ -948,8 +948,8 @@ describe('InputPrompt', () => {
mockBuffer.lines = ['@src/file👍.txt hello']; mockBuffer.lines = ['@src/file👍.txt hello'];
mockBuffer.cursor = [0, 20]; // After the space mockBuffer.cursor = [0, 20]; // After the space
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: false, showSuggestions: false,
suggestions: [], suggestions: [],
}); });
@ -957,7 +957,7 @@ describe('InputPrompt', () => {
const { unmount } = render(<InputPrompt {...props} />); const { unmount } = render(<InputPrompt {...props} />);
await wait(); await wait();
expect(mockedUseSlashCompletion).toHaveBeenCalledWith( expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
mockBuffer, mockBuffer,
['/test/project/src'], ['/test/project/src'],
path.join('test', 'project', 'src'), path.join('test', 'project', 'src'),
@ -976,8 +976,8 @@ describe('InputPrompt', () => {
mockBuffer.lines = ['@src/my\\ file.txt']; mockBuffer.lines = ['@src/my\\ file.txt'];
mockBuffer.cursor = [0, 16]; // After the escaped space and filename mockBuffer.cursor = [0, 16]; // After the escaped space and filename
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [{ label: 'my file.txt', value: 'my file.txt' }], suggestions: [{ label: 'my file.txt', value: 'my file.txt' }],
}); });
@ -985,7 +985,7 @@ describe('InputPrompt', () => {
const { unmount } = render(<InputPrompt {...props} />); const { unmount } = render(<InputPrompt {...props} />);
await wait(); await wait();
expect(mockedUseSlashCompletion).toHaveBeenCalledWith( expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
mockBuffer, mockBuffer,
['/test/project/src'], ['/test/project/src'],
path.join('test', 'project', 'src'), path.join('test', 'project', 'src'),
@ -1004,8 +1004,8 @@ describe('InputPrompt', () => {
mockBuffer.lines = ['@path/my\\ file.txt hello']; mockBuffer.lines = ['@path/my\\ file.txt hello'];
mockBuffer.cursor = [0, 24]; // After "hello" mockBuffer.cursor = [0, 24]; // After "hello"
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: false, showSuggestions: false,
suggestions: [], suggestions: [],
}); });
@ -1013,7 +1013,7 @@ describe('InputPrompt', () => {
const { unmount } = render(<InputPrompt {...props} />); const { unmount } = render(<InputPrompt {...props} />);
await wait(); await wait();
expect(mockedUseSlashCompletion).toHaveBeenCalledWith( expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
mockBuffer, mockBuffer,
['/test/project/src'], ['/test/project/src'],
path.join('test', 'project', 'src'), path.join('test', 'project', 'src'),
@ -1032,8 +1032,8 @@ describe('InputPrompt', () => {
mockBuffer.lines = ['@docs/my\\ long\\ file\\ name.md']; mockBuffer.lines = ['@docs/my\\ long\\ file\\ name.md'];
mockBuffer.cursor = [0, 29]; // At the end mockBuffer.cursor = [0, 29]; // At the end
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [ suggestions: [
{ label: 'my long file name.md', value: 'my long file name.md' }, { label: 'my long file name.md', value: 'my long file name.md' },
@ -1043,7 +1043,7 @@ describe('InputPrompt', () => {
const { unmount } = render(<InputPrompt {...props} />); const { unmount } = render(<InputPrompt {...props} />);
await wait(); await wait();
expect(mockedUseSlashCompletion).toHaveBeenCalledWith( expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
mockBuffer, mockBuffer,
['/test/project/src'], ['/test/project/src'],
path.join('test', 'project', 'src'), path.join('test', 'project', 'src'),
@ -1062,8 +1062,8 @@ describe('InputPrompt', () => {
mockBuffer.lines = ['/memory\\ test']; mockBuffer.lines = ['/memory\\ test'];
mockBuffer.cursor = [0, 13]; // At the end mockBuffer.cursor = [0, 13]; // At the end
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [{ label: 'test-command', value: 'test-command' }], suggestions: [{ label: 'test-command', value: 'test-command' }],
}); });
@ -1071,7 +1071,7 @@ describe('InputPrompt', () => {
const { unmount } = render(<InputPrompt {...props} />); const { unmount } = render(<InputPrompt {...props} />);
await wait(); await wait();
expect(mockedUseSlashCompletion).toHaveBeenCalledWith( expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
mockBuffer, mockBuffer,
['/test/project/src'], ['/test/project/src'],
path.join('test', 'project', 'src'), path.join('test', 'project', 'src'),
@ -1090,8 +1090,8 @@ describe('InputPrompt', () => {
mockBuffer.lines = ['@' + path.join('files', 'emoji\\ 👍\\ test.txt')]; mockBuffer.lines = ['@' + path.join('files', 'emoji\\ 👍\\ test.txt')];
mockBuffer.cursor = [0, 25]; // After the escaped space and emoji mockBuffer.cursor = [0, 25]; // After the escaped space and emoji
mockedUseSlashCompletion.mockReturnValue({ mockedUseCommandCompletion.mockReturnValue({
...mockSlashCompletion, ...mockCommandCompletion,
showSuggestions: true, showSuggestions: true,
suggestions: [ suggestions: [
{ label: 'emoji 👍 test.txt', value: 'emoji 👍 test.txt' }, { label: 'emoji 👍 test.txt', value: 'emoji 👍 test.txt' },
@ -1101,7 +1101,7 @@ describe('InputPrompt', () => {
const { unmount } = render(<InputPrompt {...props} />); const { unmount } = render(<InputPrompt {...props} />);
await wait(); await wait();
expect(mockedUseSlashCompletion).toHaveBeenCalledWith( expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
mockBuffer, mockBuffer,
['/test/project/src'], ['/test/project/src'],
path.join('test', 'project', 'src'), path.join('test', 'project', 'src'),

View File

@ -15,7 +15,7 @@ import chalk from 'chalk';
import stringWidth from 'string-width'; import stringWidth from 'string-width';
import { useShellHistory } from '../hooks/useShellHistory.js'; import { useShellHistory } from '../hooks/useShellHistory.js';
import { useReverseSearchCompletion } from '../hooks/useReverseSearchCompletion.js'; import { useReverseSearchCompletion } from '../hooks/useReverseSearchCompletion.js';
import { useSlashCompletion } from '../hooks/useSlashCompletion.js'; import { useCommandCompletion } from '../hooks/useCommandCompletion.js';
import { useKeypress, Key } from '../hooks/useKeypress.js'; import { useKeypress, Key } from '../hooks/useKeypress.js';
import { CommandContext, SlashCommand } from '../commands/types.js'; import { CommandContext, SlashCommand } from '../commands/types.js';
import { Config } from '@google/gemini-cli-core'; import { Config } from '@google/gemini-cli-core';
@ -78,7 +78,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
const shellHistory = useShellHistory(config.getProjectRoot()); const shellHistory = useShellHistory(config.getProjectRoot());
const historyData = shellHistory.history; const historyData = shellHistory.history;
const completion = useSlashCompletion( const completion = useCommandCompletion(
buffer, buffer,
dirs, dirs,
config.getTargetDir(), config.getTargetDir(),

View File

@ -8,7 +8,7 @@
import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest'; import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest';
import { renderHook, act, waitFor } from '@testing-library/react'; 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 fs from 'fs/promises';
import * as path from 'path'; import * as path from 'path';
import * as os from 'os'; 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 { Config, FileDiscoveryService } from '@google/gemini-cli-core';
import { useTextBuffer } from '../components/shared/text-buffer.js'; import { useTextBuffer } from '../components/shared/text-buffer.js';
describe('useSlashCompletion', () => { describe('useCommandCompletion', () => {
let testRootDir: string; let testRootDir: string;
let mockConfig: Config; let mockConfig: Config;
@ -82,7 +82,7 @@ describe('useSlashCompletion', () => {
{ name: 'dummy', description: 'dummy' }, { name: 'dummy', description: 'dummy' },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest(''), useTextBufferForTest(''),
testDirs, testDirs,
testRootDir, testRootDir,
@ -113,7 +113,7 @@ describe('useSlashCompletion', () => {
const { result, rerender } = renderHook( const { result, rerender } = renderHook(
({ text }) => { ({ text }) => {
const textBuffer = useTextBufferForTest(text); const textBuffer = useTextBufferForTest(text);
return useSlashCompletion( return useCommandCompletion(
textBuffer, textBuffer,
testDirs, testDirs,
testRootDir, testRootDir,
@ -145,7 +145,7 @@ describe('useSlashCompletion', () => {
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/help'), useTextBufferForTest('/help'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -184,7 +184,7 @@ describe('useSlashCompletion', () => {
{ name: 'dummy', description: 'dummy' }, { name: 'dummy', description: 'dummy' },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest(''), useTextBufferForTest(''),
testDirs, testDirs,
testRootDir, testRootDir,
@ -207,7 +207,7 @@ describe('useSlashCompletion', () => {
{ name: 'dummy', description: 'dummy' }, { name: 'dummy', description: 'dummy' },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest(''), useTextBufferForTest(''),
testDirs, testDirs,
testRootDir, testRootDir,
@ -234,7 +234,7 @@ describe('useSlashCompletion', () => {
}, },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/h'), useTextBufferForTest('/h'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -264,7 +264,7 @@ describe('useSlashCompletion', () => {
}, },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/h'), useTextBufferForTest('/h'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -295,7 +295,7 @@ describe('useSlashCompletion', () => {
{ name: 'chat', description: 'Manage chat' }, { name: 'chat', description: 'Manage chat' },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/'), useTextBufferForTest('/'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -343,7 +343,7 @@ describe('useSlashCompletion', () => {
})) as unknown as SlashCommand[]; })) as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/command'), useTextBufferForTest('/command'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -403,7 +403,7 @@ describe('useSlashCompletion', () => {
}, },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/'), useTextBufferForTest('/'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -426,7 +426,7 @@ describe('useSlashCompletion', () => {
}, },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/mem'), useTextBufferForTest('/mem'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -450,7 +450,7 @@ describe('useSlashCompletion', () => {
}, },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/usag'), // part of the word "usage" useTextBufferForTest('/usag'), // part of the word "usage"
testDirs, testDirs,
testRootDir, testRootDir,
@ -477,7 +477,7 @@ describe('useSlashCompletion', () => {
}, },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/clear'), // No trailing space useTextBufferForTest('/clear'), // No trailing space
testDirs, testDirs,
testRootDir, testRootDir,
@ -509,7 +509,7 @@ describe('useSlashCompletion', () => {
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest(query), useTextBufferForTest(query),
testDirs, testDirs,
testRootDir, testRootDir,
@ -530,7 +530,7 @@ describe('useSlashCompletion', () => {
}, },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/clear '), useTextBufferForTest('/clear '),
testDirs, testDirs,
testRootDir, testRootDir,
@ -551,7 +551,7 @@ describe('useSlashCompletion', () => {
}, },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/unknown-command'), useTextBufferForTest('/unknown-command'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -585,7 +585,7 @@ describe('useSlashCompletion', () => {
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/memory'), // Note: no trailing space useTextBufferForTest('/memory'), // Note: no trailing space
testDirs, testDirs,
testRootDir, testRootDir,
@ -623,7 +623,7 @@ describe('useSlashCompletion', () => {
}, },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/memory'), useTextBufferForTest('/memory'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -659,7 +659,7 @@ describe('useSlashCompletion', () => {
}, },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/memory a'), useTextBufferForTest('/memory a'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -691,7 +691,7 @@ describe('useSlashCompletion', () => {
}, },
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/memory dothisnow'), useTextBufferForTest('/memory dothisnow'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -734,7 +734,7 @@ describe('useSlashCompletion', () => {
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/chat resume my-ch'), useTextBufferForTest('/chat resume my-ch'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -778,7 +778,7 @@ describe('useSlashCompletion', () => {
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/chat resume '), useTextBufferForTest('/chat resume '),
testDirs, testDirs,
testRootDir, testRootDir,
@ -813,7 +813,7 @@ describe('useSlashCompletion', () => {
] as unknown as SlashCommand[]; ] as unknown as SlashCommand[];
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('/chat resume '), useTextBufferForTest('/chat resume '),
testDirs, testDirs,
testRootDir, testRootDir,
@ -843,7 +843,7 @@ describe('useSlashCompletion', () => {
await createTestFile('', 'README.md'); await createTestFile('', 'README.md');
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@s'), useTextBufferForTest('@s'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -879,7 +879,7 @@ describe('useSlashCompletion', () => {
await createTestFile('', 'src', 'index.ts'); await createTestFile('', 'src', 'index.ts');
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@src/comp'), useTextBufferForTest('@src/comp'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -907,7 +907,7 @@ describe('useSlashCompletion', () => {
await createTestFile('', 'src', 'index.ts'); await createTestFile('', 'src', 'index.ts');
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@.'), useTextBufferForTest('@.'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -941,7 +941,7 @@ describe('useSlashCompletion', () => {
await createEmptyDir('dist'); await createEmptyDir('dist');
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@d'), useTextBufferForTest('@d'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -969,7 +969,7 @@ describe('useSlashCompletion', () => {
await createTestFile('', 'README.md'); await createTestFile('', 'README.md');
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@'), useTextBufferForTest('@'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -1004,7 +1004,7 @@ describe('useSlashCompletion', () => {
.mockImplementation(() => {}); .mockImplementation(() => {});
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@'), useTextBufferForTest('@'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -1037,7 +1037,7 @@ describe('useSlashCompletion', () => {
await createEmptyDir('data'); await createEmptyDir('data');
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@d'), useTextBufferForTest('@d'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -1073,7 +1073,7 @@ describe('useSlashCompletion', () => {
await createTestFile('', 'README.md'); await createTestFile('', 'README.md');
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@'), useTextBufferForTest('@'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -1108,7 +1108,7 @@ describe('useSlashCompletion', () => {
await createTestFile('', 'temp', 'temp.log'); await createTestFile('', 'temp', 'temp.log');
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@t'), useTextBufferForTest('@t'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -1153,7 +1153,7 @@ describe('useSlashCompletion', () => {
const { result } = renderHook(() => { const { result } = renderHook(() => {
const textBuffer = useTextBufferForTest('/mem'); const textBuffer = useTextBufferForTest('/mem');
const completion = useSlashCompletion( const completion = useCommandCompletion(
textBuffer, textBuffer,
testDirs, testDirs,
testRootDir, testRootDir,
@ -1197,7 +1197,7 @@ describe('useSlashCompletion', () => {
const { result } = renderHook(() => { const { result } = renderHook(() => {
const textBuffer = useTextBufferForTest('/memory'); const textBuffer = useTextBufferForTest('/memory');
const completion = useSlashCompletion( const completion = useCommandCompletion(
textBuffer, textBuffer,
testDirs, testDirs,
testRootDir, testRootDir,
@ -1243,7 +1243,7 @@ describe('useSlashCompletion', () => {
const { result } = renderHook(() => { const { result } = renderHook(() => {
const textBuffer = useTextBufferForTest('/?'); const textBuffer = useTextBufferForTest('/?');
const completion = useSlashCompletion( const completion = useCommandCompletion(
textBuffer, textBuffer,
testDirs, testDirs,
testRootDir, testRootDir,
@ -1272,7 +1272,7 @@ describe('useSlashCompletion', () => {
it('should complete a file path', () => { it('should complete a file path', () => {
const { result } = renderHook(() => { const { result } = renderHook(() => {
const textBuffer = useTextBufferForTest('@src/fi'); const textBuffer = useTextBufferForTest('@src/fi');
const completion = useSlashCompletion( const completion = useCommandCompletion(
textBuffer, textBuffer,
testDirs, testDirs,
testRootDir, testRootDir,
@ -1302,7 +1302,7 @@ describe('useSlashCompletion', () => {
const { result } = renderHook(() => { const { result } = renderHook(() => {
const textBuffer = useTextBufferForTest(text, cursorOffset); const textBuffer = useTextBufferForTest(text, cursorOffset);
const completion = useSlashCompletion( const completion = useCommandCompletion(
textBuffer, textBuffer,
testDirs, testDirs,
testRootDir, testRootDir,
@ -1331,7 +1331,7 @@ describe('useSlashCompletion', () => {
const { result } = renderHook(() => { const { result } = renderHook(() => {
const textBuffer = useTextBufferForTest(text); const textBuffer = useTextBufferForTest(text);
const completion = useSlashCompletion( const completion = useCommandCompletion(
textBuffer, textBuffer,
testDirs, testDirs,
testRootDir, testRootDir,
@ -1363,7 +1363,7 @@ describe('useSlashCompletion', () => {
await createTestFile('', 'backup[old].txt'); await createTestFile('', 'backup[old].txt');
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@my'), useTextBufferForTest('@my'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -1390,7 +1390,7 @@ describe('useSlashCompletion', () => {
await createTestFile('', 'script(v2).sh'); await createTestFile('', 'script(v2).sh');
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@doc'), useTextBufferForTest('@doc'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -1417,7 +1417,7 @@ describe('useSlashCompletion', () => {
await createTestFile('', 'config[dev].json'); await createTestFile('', 'config[dev].json');
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@backup'), useTextBufferForTest('@backup'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -1444,7 +1444,7 @@ describe('useSlashCompletion', () => {
await createTestFile('', 'data & config {prod}.json'); await createTestFile('', 'data & config {prod}.json');
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@my'), useTextBufferForTest('@my'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -1477,7 +1477,7 @@ describe('useSlashCompletion', () => {
); );
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@projects/my'), useTextBufferForTest('@projects/my'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -1512,7 +1512,7 @@ describe('useSlashCompletion', () => {
); );
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@deep/nested/special'), useTextBufferForTest('@deep/nested/special'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -1542,7 +1542,7 @@ describe('useSlashCompletion', () => {
await createEmptyDir('data & logs'); await createEmptyDir('data & logs');
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@'), useTextBufferForTest('@'),
testDirs, testDirs,
testRootDir, testRootDir,
@ -1583,7 +1583,7 @@ describe('useSlashCompletion', () => {
await createTestFile('', 'important!.md'); await createTestFile('', 'important!.md');
const { result } = renderHook(() => const { result } = renderHook(() =>
useSlashCompletion( useCommandCompletion(
useTextBufferForTest('@'), useTextBufferForTest('@'),
testDirs, testDirs,
testRootDir, testRootDir,

View File

@ -28,7 +28,7 @@ import { isSlashCommand } from '../utils/commandUtils.js';
import { toCodePoints } from '../utils/textUtils.js'; import { toCodePoints } from '../utils/textUtils.js';
import { useCompletion } from './useCompletion.js'; import { useCompletion } from './useCompletion.js';
export interface UseSlashCompletionReturn { export interface UseCommandCompletionReturn {
suggestions: Suggestion[]; suggestions: Suggestion[];
activeSuggestionIndex: number; activeSuggestionIndex: number;
visibleStartIndex: number; visibleStartIndex: number;
@ -43,7 +43,7 @@ export interface UseSlashCompletionReturn {
handleAutocomplete: (indexToUse: number) => void; handleAutocomplete: (indexToUse: number) => void;
} }
export function useSlashCompletion( export function useCommandCompletion(
buffer: TextBuffer, buffer: TextBuffer,
dirs: readonly string[], dirs: readonly string[],
cwd: string, cwd: string,
@ -51,7 +51,7 @@ export function useSlashCompletion(
commandContext: CommandContext, commandContext: CommandContext,
reverseSearchActive: boolean = false, reverseSearchActive: boolean = false,
config?: Config, config?: Config,
): UseSlashCompletionReturn { ): UseCommandCompletionReturn {
const { const {
suggestions, suggestions,
activeSuggestionIndex, activeSuggestionIndex,