Skip to content

Commit

Permalink
Fix preview behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Aug 27, 2023
1 parent 71428bf commit c8ac15f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c8ac15f

Please sign in to comment.