(state: PromptHistoryState, prompt: RunPrompt)
| 71 | } |
| 72 | |
| 73 | export function pushPromptHistory(state: PromptHistoryState, prompt: RunPrompt): PromptHistoryState { |
| 74 | if (!prompt.text.trim()) { |
| 75 | return state |
| 76 | } |
| 77 | |
| 78 | const next = promptCopy(prompt) |
| 79 | if (state.items[state.items.length - 1] && promptSame(state.items[state.items.length - 1], next)) { |
| 80 | return { |
| 81 | ...state, |
| 82 | index: null, |
| 83 | draft: "", |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | const items = [...state.items, next].slice(-HISTORY_LIMIT) |
| 88 | return { |
| 89 | ...state, |
| 90 | items, |
| 91 | index: null, |
| 92 | draft: "", |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | export function movePromptHistory(state: PromptHistoryState, dir: -1 | 1, text: string, cursor: number): PromptMove { |
| 97 | if (state.items.length === 0) { |
no test coverage detected