File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,13 +17,23 @@ export const searchHistory = (instance: Terminal, isDown?: boolean) => {
1717 const { history, lastHistoryIndex } = instance
1818 const endOfHistory = history . length - 1
1919 let newIndex : number
20+ // If User pressed Down and history is empty, return;
2021 if ( isDown && lastHistoryIndex === 0 ) return
22+
23+ // if User pressed Up and user is currently on first executed command, return;
24+ if ( ! isDown && lastHistoryIndex === history . length ) return
25+
26+ if ( endOfHistory < 0 ) return
2127 // @TODO : still not consistent, index is duplicated once when searching down
28+
29+ // If Down key is pressed, check if value of newIndex is < 0?
30+ // At this point, if lastHistoryIndex is 1, we should show empty string.
2231 if ( isDown ) {
2332 newIndex = lastHistoryIndex - 1
33+ instance . input . value = newIndex - 1 >= 0 ? history [ newIndex - 1 ] : ''
2434 } else {
25- newIndex = lastHistoryIndex === endOfHistory ? 0 : lastHistoryIndex + 1
35+ newIndex = lastHistoryIndex + 1
36+ instance . input . value = history [ lastHistoryIndex ]
2637 }
27- instance . input . value = history [ isDown ? newIndex : lastHistoryIndex ]
2838 instance . lastHistoryIndex = newIndex
2939}
You can’t perform that action at this time.
0 commit comments