@@ -37,6 +37,7 @@ export interface PromptOptions<Self extends Prompt> {
3737 validate ?: ( ( value : string ) => string | void ) | undefined ;
3838 input ?: Readable ;
3939 output ?: Writable ;
40+ debug ?: boolean ;
4041}
4142
4243export type State = 'initial' | 'active' | 'cancel' | 'submit' | 'error' ;
@@ -188,10 +189,11 @@ export default class Prompt {
188189 const frame = this . _render ( this ) ?? '' ;
189190 if ( frame === this . _prevFrame ) return ;
190191
191- if ( this . state !== 'initial' ) {
192+ if ( this . state === 'initial' ) {
193+ this . output . write ( cursor . hide ) ;
194+ } else {
192195 const diff = diffLines ( this . _prevFrame , frame ) ;
193196 this . restoreCursor ( ) ;
194-
195197 // If a single line has changed, only update that line
196198 if ( diff && diff ?. length === 1 ) {
197199 const diffLine = diff [ 0 ] ;
@@ -200,7 +202,6 @@ export default class Prompt {
200202 const lines = frame . split ( '\n' ) ;
201203 this . output . write ( lines [ diffLine ] ) ;
202204 this . _prevFrame = frame ;
203- // TODO: handle wrapping
204205 this . output . write ( cursor . move ( 0 , lines . length - diffLine - 1 ) )
205206 return ;
206207 // If many lines have changed, rerender everything past the first line
@@ -212,14 +213,10 @@ export default class Prompt {
212213 const newLines = lines . slice ( diffLine ) ;
213214 this . output . write ( newLines . join ( '\n' ) ) ;
214215 this . _prevFrame = frame ;
215- // TODO: handle wrapping
216- this . output . write ( cursor . move ( 0 , newLines . length - 1 ) )
217216 return ;
218217 }
219218
220219 this . output . write ( erase . down ( ) ) ;
221- } else {
222- this . output . write ( cursor . hide ) ;
223220 }
224221
225222 this . output . write ( frame ) ;
0 commit comments