@@ -113,7 +113,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
113
113
return ;
114
114
}
115
115
const query = buffer . text ;
116
- const selectedSuggestion = completionSuggestions [ indexToUse ] ;
116
+ const suggestion = completionSuggestions [ indexToUse ] . value ;
117
117
118
118
if ( query . trimStart ( ) . startsWith ( '/' ) ) {
119
119
const parts = query . trimStart ( ) . substring ( 1 ) . split ( ' ' ) ;
@@ -122,11 +122,16 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
122
122
const base = query . substring ( 0 , slashIndex + 1 ) ;
123
123
124
124
const command = slashCommands . find ( ( cmd ) => cmd . name === commandName ) ;
125
- if ( command && command . completion ) {
126
- const newValue = `${ base } ${ commandName } ${ selectedSuggestion . value } ` ;
127
- buffer . setText ( newValue ) ;
125
+ // Make sure completion isn't the original command when command.completigion hasn't happened yet.
126
+ if ( command && command . completion && suggestion !== commandName ) {
127
+ const newValue = `${ base } ${ commandName } ${ suggestion } ` ;
128
+ if ( newValue === query ) {
129
+ handleSubmitAndClear ( newValue ) ;
130
+ } else {
131
+ buffer . setText ( newValue ) ;
132
+ }
128
133
} else {
129
- const newValue = base + selectedSuggestion . value ;
134
+ const newValue = base + suggestion ;
130
135
buffer . setText ( newValue ) ;
131
136
handleSubmitAndClear ( newValue ) ;
132
137
}
@@ -142,7 +147,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
142
147
buffer . replaceRangeByOffset (
143
148
autoCompleteStartIndex ,
144
149
buffer . text . length ,
145
- selectedSuggestion . value ,
150
+ suggestion ,
146
151
) ;
147
152
}
148
153
resetCompletionState ( ) ;
0 commit comments