@@ -720,16 +720,16 @@ Interface.prototype._historyPrev = function() {
720720Interface . prototype . _getDisplayPos = function ( str ) {
721721 let offset = 0 ;
722722 const col = this . columns ;
723- let row = 0 ;
723+ let rows = 0 ;
724724 str = stripVTControlCharacters ( str ) ;
725725 for ( let i = 0 , len = str . length ; i < len ; i ++ ) {
726726 const code = str . codePointAt ( i ) ;
727727 if ( code >= kUTF16SurrogateThreshold ) { // Surrogates.
728728 i ++ ;
729729 }
730730 if ( code === 0x0a ) { // new line \n
731- // row must be incremented by 1 even if offset = 0 or col = +Infinity
732- row += MathCeil ( offset / col ) || 1 ;
731+ // rows must be incremented by 1 even if offset = 0 or col = +Infinity
732+ rows += MathCeil ( offset / col ) || 1 ;
733733 offset = 0 ;
734734 continue ;
735735 }
@@ -744,17 +744,16 @@ Interface.prototype._getDisplayPos = function(str) {
744744 }
745745 }
746746 const cols = offset % col ;
747- const rows = row + ( offset - cols ) / col ;
748- return { cols : cols , rows : rows } ;
747+ rows += ( offset - cols ) / col ;
748+ return { cols, rows } ;
749749} ;
750750
751751
752752// Returns current cursor's position and line
753753Interface . prototype . getCursorPos = function ( ) {
754754 const columns = this . columns ;
755755 const strBeforeCursor = this . _prompt + this . line . substring ( 0 , this . cursor ) ;
756- const dispPos = this . _getDisplayPos (
757- stripVTControlCharacters ( strBeforeCursor ) ) ;
756+ const dispPos = this . _getDisplayPos ( strBeforeCursor ) ;
758757 let cols = dispPos . cols ;
759758 let rows = dispPos . rows ;
760759 // If the cursor is on a full-width character which steps over the line,
@@ -765,7 +764,7 @@ Interface.prototype.getCursorPos = function() {
765764 rows ++ ;
766765 cols = 0 ;
767766 }
768- return { cols : cols , rows : rows } ;
767+ return { cols, rows } ;
769768} ;
770769Interface . prototype . _getCursorPos = Interface . prototype . getCursorPos ;
771770
0 commit comments