@@ -70,7 +70,6 @@ export interface AutocompleteOptions<Value> extends AutocompleteSharedOptions<Va
7070export const autocomplete = < Value > ( opts : AutocompleteOptions < Value > ) => {
7171 const prompt = new AutocompletePrompt ( {
7272 options : opts . options ,
73- placeholder : opts . placeholder ,
7473 initialValue : opts . initialValue ? [ opts . initialValue ] : undefined ,
7574 filter : ( search : string , opt : Option < Value > ) => {
7675 return getFilteredOption ( search , opt ) ;
@@ -81,6 +80,8 @@ export const autocomplete = <Value>(opts: AutocompleteOptions<Value>) => {
8180 // Title and message display
8281 const title = `${ color . gray ( S_BAR ) } \n${ symbol ( this . state ) } ${ opts . message } \n` ;
8382 const valueAsString = String ( this . value ?? '' ) ;
83+ const placeholder = opts . placeholder ;
84+ const showPlaceholder = valueAsString === '' && placeholder !== undefined ;
8485
8586 // Handle different states
8687 switch ( this . state ) {
@@ -97,7 +98,10 @@ export const autocomplete = <Value>(opts: AutocompleteOptions<Value>) => {
9798
9899 default : {
99100 // 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 ;
101105
102106 // Show match count if filtered
103107 const matches =
@@ -209,7 +213,6 @@ export const autocompleteMultiselect = <Value>(opts: AutocompleteMultiSelectOpti
209213 }
210214 return undefined ;
211215 } ,
212- placeholder : opts . placeholder ,
213216 initialValue : opts . initialValues ,
214217 input : opts . input ,
215218 output : opts . output ,
@@ -219,11 +222,14 @@ export const autocompleteMultiselect = <Value>(opts: AutocompleteMultiSelectOpti
219222
220223 // Selection counter
221224 const value = String ( this . value ?? '' ) ;
225+ const placeholder = opts . placeholder ;
226+ const showPlaceholder = value === '' && placeholder !== undefined ;
222227
223228 // 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 ;
227233
228234 const matches =
229235 this . filteredOptions . length !== opts . options . length
0 commit comments