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

Function navigateUp

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

setInputModeFunction · 0.85
setInputValueFunction · 0.85
parseHistoryItemFunction · 0.70

Tested by

no test coverage detected