diff --git a/internal/tui/components/chat/editor/editor.go b/internal/tui/components/chat/editor/editor.go index a356f7319d62c3652c13084b63c4b4faaedd3a03..83fa60676d13400179bdc1714ee26df6b1351a32 100644 --- a/internal/tui/components/chat/editor/editor.go +++ b/internal/tui/components/chat/editor/editor.go @@ -659,7 +659,9 @@ func (m *editorCmp) stepOverHistory(resolveHistoricMessages func(context.Context } defer func() { - m.scrollingPromptHistory = m.promptHistoryIndex < len(messageHistory)-1 + if !m.scrollingPromptHistory { + m.scrollingPromptHistory = m.promptHistoryIndex < len(messageHistory)-2 + } }() switch resolveDirection() { @@ -681,8 +683,12 @@ func (m *editorCmp) stepBack(history []string) string { func (m *editorCmp) stepForward(history []string) string { m.promptHistoryIndex += 1 - if m.promptHistoryIndex >= len(history)-1 { - m.promptHistoryIndex = len(history) - 1 + if m.promptHistoryIndex > len(history)-1 { + offset := 1 + if m.scrollingPromptHistory { + offset = 2 + } + m.promptHistoryIndex = len(history) - offset } return history[m.promptHistoryIndex] }