()
| 172 | } |
| 173 | |
| 174 | const navigateDown = () => { |
| 175 | const history = state.messageHistory |
| 176 | if (history.length === 0) return |
| 177 | if (state.historyIndex === -1) return |
| 178 | |
| 179 | state.isNavigating = true |
| 180 | |
| 181 | if (state.historyIndex < history.length - 1) { |
| 182 | state.historyIndex += 1 |
| 183 | const historyMessage = history[state.historyIndex] |
| 184 | if (historyMessage === undefined) { |
| 185 | state.isNavigating = false |
| 186 | return |
| 187 | } |
| 188 | |
| 189 | const { mode, displayText } = parseHistoryItem(historyMessage) |
| 190 | |
| 191 | // Switch mode if needed |
| 192 | if (mode !== state.inputMode) { |
| 193 | setInputMode(mode) |
| 194 | } |
| 195 | |
| 196 | setInputValue({ |
| 197 | text: displayText, |
| 198 | cursorPosition: displayText.length, |
| 199 | lastEditDueToNav: true, |
| 200 | }) |
| 201 | } else { |
| 202 | state.historyIndex = -1 |
| 203 | const draft = state.currentDraft |
| 204 | const draftMode = state.currentDraftMode |
| 205 | |
| 206 | if (draftMode !== state.inputMode) { |
| 207 | setInputMode(draftMode) |
| 208 | } |
| 209 | |
| 210 | const textToShow = |
| 211 | draftMode === 'bash' && draft.startsWith('!') ? draft.slice(1) : draft |
| 212 | |
| 213 | setInputValue({ |
| 214 | text: textToShow, |
| 215 | cursorPosition: textToShow.length, |
| 216 | lastEditDueToNav: true, |
| 217 | }) |
| 218 | } |
| 219 | |
| 220 | state.isNavigating = false |
| 221 | } |
| 222 | |
| 223 | const simulateInputModeChange = (newMode: InputMode) => { |
| 224 | const oldMode = state.inputMode |
nothing calls this directly
no test coverage detected