From c8ac15f753f51f443ca29011f86380e2a03ed2c8 Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Sun, 27 Aug 2023 16:11:24 +0200 Subject: [PATCH] Fix preview behavior --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index bb75108..8f57793 100644 --- a/main.go +++ b/main.go @@ -192,7 +192,6 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } m.updateOffset() m.saveCursorPosition() - m.preview() // Save search id to clear only current search after delay. // User may have already started typing next search. searchId := m.searchId @@ -252,7 +251,6 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.findPrevName = true } m.list() - m.preview() return m, nil case key.Matches(msg, keyUp): @@ -323,7 +321,6 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.findPrevName = true if m.previewMode { - m.preview() return m, tea.EnterAltScreen } else { m.previewContent = "" @@ -363,7 +360,6 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.deleteCurrentFile = false m.updateOffset() m.saveCursorPosition() - m.preview() case clearSearchMsg: if m.searchId == int(msg) { @@ -412,6 +408,10 @@ func (m *model) View() string { m.saveCursorPosition() } + // After we have updated offset and saved cursor position, we can + // preview currently selected file. + m.preview() + // Get output rows width before coloring. outputWidth := len(path.Base(m.path)) // Use current dir name as default. if m.previewMode {