File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -110,18 +110,18 @@ const Terminal = ({
110110 } ;
111111
112112 const handleInputKeyDown = ( event : KeyboardEvent < HTMLInputElement > ) => {
113- event . preventDefault ( ) ;
114113 if ( ! onInput ) {
115114 return ;
116115 }
117116 if ( event . key === "Enter" ) {
117+ event . preventDefault ( ) ;
118118 onInput ( currentLineInput ) ;
119119 setCursorPos ( 0 ) ;
120120
121121 // history update
122122 setHistory ( ( previousHistory ) =>
123123 currentLineInput . trim ( ) === "" ||
124- previousHistory [ previousHistory . length - 1 ] === currentLineInput . trim ( )
124+ previousHistory [ previousHistory . length - 1 ] === currentLineInput . trim ( )
125125 ? previousHistory
126126 : [ ...previousHistory , currentLineInput ] ,
127127 ) ;
@@ -157,10 +157,12 @@ const Terminal = ({
157157 currentLineInput . length - cursorIndex + 1 ,
158158 ) ;
159159 } else if ( event . key === "ArrowUp" ) {
160- charsToRightOfCursor = currentLineInput . slice ( 0 ) ;
160+ event . preventDefault ( ) ;
161+ charsToRightOfCursor = currentLineInput . slice ( currentLineInput . length ) ;
161162 changeHistoryIndex ( - 1 ) ;
162163 } else if ( event . key === "ArrowDown" ) {
163- charsToRightOfCursor = currentLineInput . slice ( 0 ) ;
164+ event . preventDefault ( ) ;
165+ charsToRightOfCursor = currentLineInput . slice ( currentLineInput . length ) ;
164166 changeHistoryIndex ( 1 ) ;
165167 }
166168
You can’t perform that action at this time.
0 commit comments