historyUp walks one step toward older entries; caller gates on cursor-on- first-line and popover closed. Empty history is a no-op.
()
| 136 | // historyUp walks one step toward older entries; caller gates on cursor-on- |
| 137 | // first-line and popover closed. Empty history is a no-op. |
| 138 | func (m Model) historyUp() Model { |
| 139 | if len(m.promptHistory) == 0 { |
| 140 | return m |
| 141 | } |
| 142 | // Leaving the live line: stash the unsent draft so ↓ can restore it. |
| 143 | if m.histIdx == -1 { |
| 144 | m.histDraft = m.ta.Entry() |
| 145 | } |
| 146 | if m.histIdx+1 < len(m.promptHistory) { |
| 147 | m.histIdx++ |
| 148 | } |
| 149 | m.ta.Restore(m.promptHistory[len(m.promptHistory)-1-m.histIdx]) |
| 150 | return m |
| 151 | } |
| 152 | |
| 153 | // historyDown walks one step toward newer entries; -1 is the live draft |
| 154 | // sentinel and restores an empty textarea. |