mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-30 15:04:16 -07:00
fix(ui): Prevent eager slash command completion hiding sibling commands (#15224)
This commit is contained in:
@@ -530,6 +530,52 @@ describe('useSlashCompletion', () => {
|
|||||||
unmount();
|
unmount();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should suggest parent command (and siblings) instead of sub-commands when no trailing space', async () => {
|
||||||
|
const slashCommands = [
|
||||||
|
createTestCommand({
|
||||||
|
name: 'memory',
|
||||||
|
description: 'Manage memory',
|
||||||
|
subCommands: [
|
||||||
|
createTestCommand({ name: 'show', description: 'Show memory' }),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
createTestCommand({
|
||||||
|
name: 'memory-leak',
|
||||||
|
description: 'Debug memory leaks',
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
|
||||||
|
const { result } = renderHook(() =>
|
||||||
|
useTestHarnessForSlashCompletion(
|
||||||
|
true,
|
||||||
|
'/memory',
|
||||||
|
slashCommands,
|
||||||
|
mockCommandContext,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Should verify that we see BOTH 'memory' and 'memory-leak'
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(result.current.suggestions).toHaveLength(2);
|
||||||
|
expect(result.current.suggestions).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
{
|
||||||
|
label: 'memory',
|
||||||
|
value: 'memory',
|
||||||
|
description: 'Manage memory',
|
||||||
|
commandKind: CommandKind.BUILT_IN,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'memory-leak',
|
||||||
|
value: 'memory-leak',
|
||||||
|
description: 'Debug memory leaks',
|
||||||
|
commandKind: CommandKind.BUILT_IN,
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should suggest all sub-commands when the query ends with the parent command and a space', async () => {
|
it('should suggest all sub-commands when the query ends with the parent command and a space', async () => {
|
||||||
const slashCommands = [
|
const slashCommands = [
|
||||||
createTestCommand({
|
createTestCommand({
|
||||||
@@ -892,7 +938,7 @@ describe('useSlashCompletion', () => {
|
|||||||
const { result, unmount } = renderHook(() =>
|
const { result, unmount } = renderHook(() =>
|
||||||
useTestHarnessForSlashCompletion(
|
useTestHarnessForSlashCompletion(
|
||||||
true,
|
true,
|
||||||
'/memory',
|
'/memory ',
|
||||||
slashCommands,
|
slashCommands,
|
||||||
mockCommandContext,
|
mockCommandContext,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -117,12 +117,6 @@ function useCommandParser(
|
|||||||
exactMatchAsParent = currentLevel.find(
|
exactMatchAsParent = currentLevel.find(
|
||||||
(cmd) => matchesCommand(cmd, partial) && cmd.subCommands,
|
(cmd) => matchesCommand(cmd, partial) && cmd.subCommands,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (exactMatchAsParent) {
|
|
||||||
leafCommand = exactMatchAsParent;
|
|
||||||
currentLevel = exactMatchAsParent.subCommands;
|
|
||||||
partial = '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const depth = commandPathParts.length;
|
const depth = commandPathParts.length;
|
||||||
|
|||||||
Reference in New Issue
Block a user