File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -91,15 +91,25 @@ async function conversation() {
9191 message : 'Write a message:' ,
9292 searchText : '' ,
9393 emptyText : '' ,
94- source : ( answers , input ) => {
95- return Promise . resolve (
96- input ? availableCommands . filter ( ( command ) => command . value . startsWith ( input ) ) : [ ]
97- ) ;
98- }
94+ suggestOnly : true ,
95+ validate : ( choice , answers ) => {
96+ return true ;
97+ } ,
98+ source : ( ) => Promise . resolve ( [ ] ) ,
9999 } ,
100100 ] ) ;
101101 // hiding the ugly autocomplete hint
102102 prompt . ui . activePrompt . firstRender = false ;
103+ // The below is a hack to allow selecting items from the autocomplete menu while also being able to submit messages.
104+ // This basically simulates a hybrid between having `suggestOnly: false` and `suggestOnly: true`.
105+ await new Promise ( ( resolve ) => setTimeout ( resolve , 0 ) ) ;
106+ prompt . ui . activePrompt . opt . source = ( answers , input ) => {
107+ if ( ! input ) {
108+ return [ ] ;
109+ }
110+ prompt . ui . activePrompt . opt . suggestOnly = ! input . startsWith ( '!' ) ;
111+ return availableCommands . filter ( ( command ) => command . value . startsWith ( input ) ) ;
112+ } ;
103113 let { message } = await prompt ;
104114 message = message . trim ( ) ;
105115 if ( ! message ) {
You can’t perform that action at this time.
0 commit comments