File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -659,7 +659,17 @@ class Interface extends InterfaceConstructor {
659659 [ kInsertString ] ( c ) {
660660 this [ kBeforeEdit ] ( this . line , this . cursor ) ;
661661 if ( ! this . isCompletionEnabled ) {
662- this . line += c ;
662+ if ( this . cursor < this . line . length ) {
663+ const beg = StringPrototypeSlice ( this . line , 0 , this . cursor ) ;
664+ const end = StringPrototypeSlice (
665+ this . line ,
666+ this . cursor ,
667+ this . line . length ,
668+ ) ;
669+ this . line = beg + c + end ;
670+ } else {
671+ this . line += c ;
672+ }
663673 this . cursor += c . length ;
664674 this [ kWriteToOutput ] ( c ) ;
665675 return ;
Original file line number Diff line number Diff line change @@ -9,6 +9,11 @@ const { startNewREPLServer } = require('../common/repl');
99const cpuUsage = process . cpuUsage ( ) ;
1010
1111const { replServer } = startNewREPLServer ( { } , { disableDomainErrorAssert : true } ) ;
12+ replServer . input . emit ( 'data' , '{}' ) ;
13+ replServer . input . emit ( 'keypress' , '' , { name : 'left' } ) ;
14+ replServer . input . emit ( 'data' , 'node' ) ;
15+ assert . strictEqual ( replServer . line , '{node}' ) ;
16+
1217replServer . input . emit ( 'data' , 'a' . repeat ( 2e4 ) + '\n' ) ;
1318replServer . input . emit ( 'data' , '.exit\n' ) ;
1419
You can’t perform that action at this time.
0 commit comments