From 85bbef35a6e98cd9584cfc4f09206713c2083086 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 1 Feb 2021 14:56:58 +0100 Subject: [PATCH] {Help,Text}Page: reset the cursor location only if invisible If the cursor still marks the previous find result, don't reset it, or else it will find the same item again. --- src/HelpPage.cxx | 8 +++++++- src/TextPage.cxx | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/HelpPage.cxx b/src/HelpPage.cxx index bc49ea19..1d8aaf72 100644 --- a/src/HelpPage.cxx +++ b/src/HelpPage.cxx @@ -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; diff --git a/src/TextPage.cxx b/src/TextPage.cxx index 78a41380..8156f132 100644 --- a/src/TextPage.cxx +++ b/src/TextPage.cxx @@ -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;