()
| 137 | } |
| 138 | |
| 139 | const navigateUp = () => { |
| 140 | const history = state.messageHistory |
| 141 | if (history.length === 0) return |
| 142 | |
| 143 | state.isNavigating = true |
| 144 | |
| 145 | if (state.historyIndex === -1) { |
| 146 | state.currentDraft = state.inputMode === 'bash' ? '!' + state.inputValue : state.inputValue |
| 147 | state.currentDraftMode = state.inputMode |
| 148 | state.historyIndex = history.length - 1 |
| 149 | } else if (state.historyIndex > 0) { |
| 150 | state.historyIndex -= 1 |
| 151 | } |
| 152 | |
| 153 | const historyMessage = history[state.historyIndex] |
| 154 | if (historyMessage === undefined) { |
| 155 | state.isNavigating = false |
| 156 | return |
| 157 | } |
| 158 | |
| 159 | const { mode, displayText } = parseHistoryItem(historyMessage) |
| 160 | |
| 161 | if (mode !== state.inputMode) { |
| 162 | setInputMode(mode) |
| 163 | } |
| 164 | |
| 165 | setInputValue({ |
| 166 | text: displayText, |
| 167 | cursorPosition: displayText.length, |
| 168 | lastEditDueToNav: true, |
| 169 | }) |
| 170 | |
| 171 | state.isNavigating = false |
| 172 | } |
| 173 | |
| 174 | const navigateDown = () => { |
| 175 | const history = state.messageHistory |
nothing calls this directly
no test coverage detected