File tree 1 file changed +14
-2
lines changed
packages/inquirer/lib/prompts
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ class RawListPrompt extends Base {
15
15
constructor ( questions , rl , answers ) {
16
16
super ( questions , rl , answers ) ;
17
17
18
+ this . hiddenLine = '' ;
19
+ this . lastKey = '' ;
20
+
18
21
if ( ! this . opt . choices ) {
19
22
this . throwParamError ( 'choices' ) ;
20
23
}
@@ -145,7 +148,14 @@ class RawListPrompt extends Base {
145
148
*/
146
149
147
150
onKeypress ( ) {
148
- const index = this . rl . line . length ? Number ( this . rl . line ) - 1 : 0 ;
151
+ let index ;
152
+
153
+ if ( this . lastKey === 'arrow' ) {
154
+ index = this . hiddenLine . length ? Number ( this . hiddenLine ) - 1 : 0 ;
155
+ } else {
156
+ index = this . rl . line . length ? Number ( this . rl . line ) - 1 : 0 ;
157
+ }
158
+ this . lastKey = '' ;
149
159
150
160
if ( this . opt . choices . getChoice ( index ) ) {
151
161
this . selected = index ;
@@ -178,7 +188,9 @@ class RawListPrompt extends Base {
178
188
179
189
onArrowKey ( type ) {
180
190
this . selected = incrementListIndex ( this . selected , type , this . opt ) ;
181
- this . rl . line = String ( this . selected + 1 ) ;
191
+ this . hiddenLine = String ( this . selected + 1 ) ;
192
+ this . rl . line = '' ;
193
+ this . lastKey = 'arrow' ;
182
194
}
183
195
}
184
196
You can’t perform that action at this time.
0 commit comments