Skip to content

Commit

Permalink
{Help,Text}Page: reset the cursor location only if invisible
Browse files Browse the repository at this point in the history
If the cursor still marks the previous find result, don't reset it, or
else it will find the same item again.
  • Loading branch information
MaxKellermann committed Feb 1, 2021
1 parent 2bbc11d commit 85bbef3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/HelpPage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,13 @@ HelpPage::OnCommand(struct mpdclient &c, Command cmd)
if (ListPage::OnCommand(c, cmd))
return true;

lw.SetCursorFromOrigin(0);
if (!lw.IsCursorVisible())
/* start searching at the beginning of the page (not
where the invisible cursor just happens to be),
unless the cursor is still visible from the last
search */
lw.SetCursorFromOrigin(0);

if (screen_find(screen, lw, cmd, *this)) {
SetDirty();
return true;
Expand Down
8 changes: 7 additions & 1 deletion src/TextPage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ TextPage::OnCommand(struct mpdclient &c, Command cmd)
if (ListPage::OnCommand(c, cmd))
return true;

lw.SetCursorFromOrigin(0);
if (!lw.IsCursorVisible())
/* start searching at the beginning of the page (not
where the invisible cursor just happens to be),
unless the cursor is still visible from the last
search */
lw.SetCursorFromOrigin(0);

if (screen_find(screen, lw, cmd, *this)) {
SetDirty();
return true;
Expand Down

0 comments on commit 85bbef3

Please sign in to comment.