1- import { AutocompletePrompt } from '@clack/core' ;
1+ import { AutocompletePrompt , settings } from '@clack/core' ;
22import color from 'picocolors' ;
33import {
44 type CommonOptions ,
@@ -95,8 +95,11 @@ export const autocomplete = <Value>(opts: AutocompleteOptions<Value>) => {
9595 output : opts . output ,
9696 validate : opts . validate ,
9797 render ( ) {
98+ const hasGuide = opts . withGuide ?? settings . withGuide ;
9899 // Title and message display
99- const headings = [ `${ color . gray ( S_BAR ) } ` , `${ symbol ( this . state ) } ${ opts . message } ` ] ;
100+ const headings = hasGuide
101+ ? [ `${ color . gray ( S_BAR ) } ` , `${ symbol ( this . state ) } ${ opts . message } ` ]
102+ : [ `${ symbol ( this . state ) } ${ opts . message } ` ] ;
100103 const userInput = this . userInput ;
101104 const options = this . options ;
102105 const placeholder = opts . placeholder ;
@@ -109,17 +112,20 @@ export const autocomplete = <Value>(opts: AutocompleteOptions<Value>) => {
109112 const selected = getSelectedOptions ( this . selectedValues , options ) ;
110113 const label =
111114 selected . length > 0 ? ` ${ color . dim ( selected . map ( getLabel ) . join ( ', ' ) ) } ` : '' ;
112- return `${ headings . join ( '\n' ) } \n${ color . gray ( S_BAR ) } ${ label } ` ;
115+ const submitPrefix = hasGuide ? color . gray ( S_BAR ) : '' ;
116+ return `${ headings . join ( '\n' ) } \n${ submitPrefix } ${ label } ` ;
113117 }
114118
115119 case 'cancel' : {
116120 const userInputText = userInput ? ` ${ color . strikethrough ( color . dim ( userInput ) ) } ` : '' ;
117- return `${ headings . join ( '\n' ) } \n${ color . gray ( S_BAR ) } ${ userInputText } ` ;
121+ const cancelPrefix = hasGuide ? color . gray ( S_BAR ) : '' ;
122+ return `${ headings . join ( '\n' ) } \n${ cancelPrefix } ${ userInputText } ` ;
118123 }
119124
120125 default : {
121- const guidePrefix = `${ ( this . state === 'error' ? color . yellow : color . cyan ) ( S_BAR ) } ` ;
122- const guidePrefixEnd = ( this . state === 'error' ? color . yellow : color . cyan ) ( S_BAR_END ) ;
126+ const barColor = this . state === 'error' ? color . yellow : color . cyan ;
127+ const guidePrefix = hasGuide ? `${ barColor ( S_BAR ) } ` : '' ;
128+ const guidePrefixEnd = hasGuide ? barColor ( S_BAR_END ) : '' ;
123129 // Display cursor position - show plain text in navigation mode
124130 let searchText = '' ;
125131 if ( this . isNavigating || showPlaceholder ) {
@@ -146,8 +152,10 @@ export const autocomplete = <Value>(opts: AutocompleteOptions<Value>) => {
146152 const validationError =
147153 this . state === 'error' ? [ `${ guidePrefix } ${ color . yellow ( this . error ) } ` ] : [ ] ;
148154
155+ if ( hasGuide ) {
156+ headings . push ( `${ guidePrefix . trimEnd ( ) } ` ) ;
157+ }
149158 headings . push (
150- `${ guidePrefix . trimEnd ( ) } ` ,
151159 `${ guidePrefix } ${ color . dim ( 'Search:' ) } ${ searchText } ${ matches } ` ,
152160 ...noResults ,
153161 ...validationError
@@ -161,8 +169,8 @@ export const autocomplete = <Value>(opts: AutocompleteOptions<Value>) => {
161169 ] ;
162170
163171 const footers = [
164- `${ guidePrefix } ${ color . dim ( instructions . join ( ' • ' ) ) } ` ,
165- ` ${ guidePrefixEnd } ` ,
172+ `${ guidePrefix } ${ instructions . join ( ' • ' ) } ` ,
173+ guidePrefixEnd ,
166174 ] ;
167175
168176 // Render options with selection
@@ -172,7 +180,7 @@ export const autocomplete = <Value>(opts: AutocompleteOptions<Value>) => {
172180 : limitOptions ( {
173181 cursor : this . cursor ,
174182 options : this . filteredOptions ,
175- columnPadding : 3 , // for `| `
183+ columnPadding : hasGuide ? 3 : 0 , // for `| ` when guide is shown
176184 rowPadding : headings . length + footers . length ,
177185 style : ( option , active ) => {
178186 const label = getLabel ( option ) ;
@@ -318,7 +326,7 @@ export const autocompleteMultiselect = <Value>(opts: AutocompleteMultiSelectOpti
318326 ...errorMessage ,
319327 ] ;
320328 const footerLines = [
321- `${ barColor ( S_BAR ) } ${ color . dim ( instructions . join ( ' • ' ) ) } ` ,
329+ `${ barColor ( S_BAR ) } ${ instructions . join ( ' • ' ) } ` ,
322330 `${ barColor ( S_BAR_END ) } ` ,
323331 ] ;
324332
0 commit comments