summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/components/SuggestionsDisplay.tsx
diff options
context:
space:
mode:
authorAyesha Shafique <[email protected]>2025-08-04 00:53:24 +0500
committerGitHub <[email protected]>2025-08-03 19:53:24 +0000
commit072d8ba2899f2601dad6d4b0333fdcb80555a7dd (patch)
treea8333f75184889929b844c115c5fb93555abdf62 /packages/cli/src/ui/components/SuggestionsDisplay.tsx
parent03ed37d0dc2b5e2077b53073517abaab3d24d9c2 (diff)
feat: Add reverse search capability for shell commands (#4793)
Diffstat (limited to 'packages/cli/src/ui/components/SuggestionsDisplay.tsx')
-rw-r--r--packages/cli/src/ui/components/SuggestionsDisplay.tsx17
1 files changed, 13 insertions, 4 deletions
diff --git a/packages/cli/src/ui/components/SuggestionsDisplay.tsx b/packages/cli/src/ui/components/SuggestionsDisplay.tsx
index 0620665f..9c4b5687 100644
--- a/packages/cli/src/ui/components/SuggestionsDisplay.tsx
+++ b/packages/cli/src/ui/components/SuggestionsDisplay.tsx
@@ -6,10 +6,12 @@
import { Box, Text } from 'ink';
import { Colors } from '../colors.js';
+import { PrepareLabel } from './PrepareLabel.js';
export interface Suggestion {
label: string;
value: string;
description?: string;
+ matchedIndex?: number;
}
interface SuggestionsDisplayProps {
suggestions: Suggestion[];
@@ -58,18 +60,25 @@ export function SuggestionsDisplay({
const originalIndex = startIndex + index;
const isActive = originalIndex === activeIndex;
const textColor = isActive ? Colors.AccentPurple : Colors.Gray;
+ const labelElement = (
+ <PrepareLabel
+ label={suggestion.label}
+ matchedIndex={suggestion.matchedIndex}
+ userInput={userInput}
+ textColor={textColor}
+ />
+ );
return (
- <Box key={`${suggestion}-${originalIndex}`} width={width}>
+ <Box key={`${suggestion.value}-${originalIndex}`} width={width}>
<Box flexDirection="row">
{userInput.startsWith('/') ? (
// only use box model for (/) command mode
<Box width={20} flexShrink={0}>
- <Text color={textColor}>{suggestion.label}</Text>
+ {labelElement}
</Box>
) : (
- // use regular text for other modes (@ context)
- <Text color={textColor}>{suggestion.label}</Text>
+ labelElement
)}
{suggestion.description ? (
<Box flexGrow={1}>