MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / navigateDown

Function navigateDown

cli/src/hooks/__tests__/use-input-history.test.ts:174–221  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

setInputModeFunction · 0.85
setInputValueFunction · 0.85
parseHistoryItemFunction · 0.70

Tested by

no test coverage detected