From 7fb4a43474495954ed65061bedf622e618bb6ff3 Mon Sep 17 00:00:00 2001 From: Nicolas Martin Date: Sun, 25 Oct 2020 04:51:23 +0100 Subject: [PATCH] Fix cursor placement when paging trough filtered notes --- ui/stash.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ui/stash.go b/ui/stash.go index 3b5330b..340b22d 100644 --- a/ui/stash.go +++ b/ui/stash.go @@ -661,6 +661,19 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) { break } + // When there's only one filtered markdown left and the cursor + // is placed on it we can diretly "enter" it and change to the + // markdown view + if h := m.getNotes(); len(h) == 1 && h[0].ID == m.selectedMarkdown().ID { + m.state = stashStateReady + m.searchInput.Reset() + + var cmd tea.Cmd + m, cmd = stashUpdate(msg, m) + cmds = append(cmds, cmd) + break + } + m.searchInput.Blur() m.state = stashStateShowFiltered