@@ -70,7 +70,6 @@ export interface AutocompleteOptions<Value> extends AutocompleteSharedOptions<Va
70
70
export const autocomplete = < Value > ( opts : AutocompleteOptions < Value > ) => {
71
71
const prompt = new AutocompletePrompt ( {
72
72
options : opts . options ,
73
- placeholder : opts . placeholder ,
74
73
initialValue : opts . initialValue ? [ opts . initialValue ] : undefined ,
75
74
filter : ( search : string , opt : Option < Value > ) => {
76
75
return getFilteredOption ( search , opt ) ;
@@ -81,6 +80,8 @@ export const autocomplete = <Value>(opts: AutocompleteOptions<Value>) => {
81
80
// Title and message display
82
81
const title = `${ color . gray ( S_BAR ) } \n${ symbol ( this . state ) } ${ opts . message } \n` ;
83
82
const valueAsString = String ( this . value ?? '' ) ;
83
+ const placeholder = opts . placeholder ;
84
+ const showPlaceholder = valueAsString === '' && placeholder !== undefined ;
84
85
85
86
// Handle different states
86
87
switch ( this . state ) {
@@ -97,7 +98,10 @@ export const autocomplete = <Value>(opts: AutocompleteOptions<Value>) => {
97
98
98
99
default : {
99
100
// Display cursor position - show plain text in navigation mode
100
- const searchText = this . isNavigating ? color . dim ( valueAsString ) : this . valueWithCursor ;
101
+ const searchText =
102
+ this . isNavigating || showPlaceholder
103
+ ? color . dim ( showPlaceholder ? placeholder : valueAsString )
104
+ : this . valueWithCursor ;
101
105
102
106
// Show match count if filtered
103
107
const matches =
@@ -209,7 +213,6 @@ export const autocompleteMultiselect = <Value>(opts: AutocompleteMultiSelectOpti
209
213
}
210
214
return undefined ;
211
215
} ,
212
- placeholder : opts . placeholder ,
213
216
initialValue : opts . initialValues ,
214
217
input : opts . input ,
215
218
output : opts . output ,
@@ -219,11 +222,14 @@ export const autocompleteMultiselect = <Value>(opts: AutocompleteMultiSelectOpti
219
222
220
223
// Selection counter
221
224
const value = String ( this . value ?? '' ) ;
225
+ const placeholder = opts . placeholder ;
226
+ const showPlaceholder = value === '' && placeholder !== undefined ;
222
227
223
228
// Search input display
224
- const searchText = this . isNavigating
225
- ? color . dim ( value ) // Just show plain text when in navigation mode
226
- : this . valueWithCursor ;
229
+ const searchText =
230
+ this . isNavigating || showPlaceholder
231
+ ? color . dim ( showPlaceholder ? placeholder : value ) // Just show plain text when in navigation mode
232
+ : this . valueWithCursor ;
227
233
228
234
const matches =
229
235
this . filteredOptions . length !== opts . options . length
0 commit comments