@@ -936,14 +936,17 @@ class Interface extends InterfaceConstructor {
936936 [ kMoveDownOrHistoryNext ] ( ) {
937937 const { cols, rows } = this . getCursorPos ( ) ;
938938 const splitLine = StringPrototypeSplit ( this . line , '\n' ) ;
939+ if ( ! this . historyIndex && rows === splitLine . length ) {
940+ return ;
941+ }
939942 // Go to the next history only if the cursor is in the first line of the multiline input.
940943 // Otherwise treat the "arrow down" as a movement to the next row.
941944 if ( splitLine . length > 1 && rows < splitLine . length - 1 ) {
942945 const currentLine = splitLine [ rows ] ;
943946 const nextLine = splitLine [ rows + 1 ] ;
944947 const amountToMove = ( cols > nextLine . length ) ?
945- + cols + nextLine . length - 1 :
946- + currentLine . length + 1 ;
948+ currentLine . length - cols + nextLine . length + 1 :
949+ currentLine . length + 1 ;
947950 // Go to the same position on the next line, or the end of the next line
948951 // If the current position does not exist in the next line.
949952 this [ kMoveCursor ] ( amountToMove ) ;
@@ -963,9 +966,7 @@ class Interface extends InterfaceConstructor {
963966 [ kHistoryNext ] ( ) {
964967 if ( this . historyIndex >= 0 ) {
965968 this [ kBeforeEdit ] ( this . line , this . cursor ) ;
966- const isLineMultiline = StringPrototypeIndexOf ( this . line , '\n' ) !== - 1 ;
967-
968- const search = isLineMultiline ? '' : this [ kSubstringSearch ] || '' ;
969+ const search = this [ kSubstringSearch ] || '' ;
969970 let index = this . historyIndex - 1 ;
970971 while (
971972 index >= 0 &&
@@ -987,6 +988,9 @@ class Interface extends InterfaceConstructor {
987988
988989 [ kMoveUpOrHistoryPrev ] ( ) {
989990 const { cols, rows } = this . getCursorPos ( ) ;
991+ if ( this . historyIndex === this . history . length && rows ) {
992+ return ;
993+ }
990994 const splitLine = StringPrototypeSplit ( this . line , '\n' ) ;
991995 // Go to the previous history only if the cursor is in the first line of the multiline input.
992996 // Otherwise treat the "arrow up" as a movement to the previous row.
@@ -1007,9 +1011,7 @@ class Interface extends InterfaceConstructor {
10071011 [ kHistoryPrev ] ( ) {
10081012 if ( this . historyIndex < this . history . length && this . history . length ) {
10091013 this [ kBeforeEdit ] ( this . line , this . cursor ) ;
1010- const isLineMultiline = StringPrototypeIndexOf ( this . line , '\n' ) !== - 1 ;
1011-
1012- const search = isLineMultiline ? '' : this [ kSubstringSearch ] || '' ;
1014+ const search = this [ kSubstringSearch ] || '' ;
10131015 let index = this . historyIndex + 1 ;
10141016 while (
10151017 index < this . history . length &&
@@ -1122,7 +1124,8 @@ class Interface extends InterfaceConstructor {
11221124 ! key . meta &&
11231125 ! key . shift
11241126 ) {
1125- if ( this [ kSubstringSearch ] === null ) {
1127+ const isLineMultiline = StringPrototypeIndexOf ( this . line , '\n' ) !== - 1 ;
1128+ if ( this [ kSubstringSearch ] === null && ! isLineMultiline ) {
11261129 this [ kSubstringSearch ] = StringPrototypeSlice (
11271130 this . line ,
11281131 0 ,
0 commit comments