]> git.neil.brown.name Git - edlib.git/commitdiff
history: improve stability of search.
authorNeilBrown <neil@brown.name>
Fri, 21 Jul 2023 08:29:18 +0000 (18:29 +1000)
committerNeilBrown <neil@brown.name>
Fri, 21 Jul 2023 08:29:18 +0000 (18:29 +1000)
When searching for string that matched at start of line, we would stay
on the line as we typed more of the match.
When searching elsewhere, we keep moving backward in the history.

Fix by always starting search at end of line.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/TODO.md
lib-history.c

index 2711a537c3022ab80d42937e757a2bd4bef32e11..190d72b3b2ddc40b52100d0d0f40baab9e957803 100644 (file)
@@ -26,7 +26,7 @@ the file.
       When searching backwards and result is just above display, the
       result doesn't get shown.  Sometimes.
 - [X] visiting a new file from a 44 popup is weird.
-- [ ] search in history always finds a new history line.  It doesn't
+- [X] search in history always finds a new history line.  It doesn't
       check if new patterns still matches this line.
 - [ ] in notmuch cursor should go to query result when changing
       messages.
index a90e4b450a82b0354667b769c2af72d587c05752..b7bceb15e96fbb64529a6af08e1ef4cbd46162bf 100644 (file)
@@ -362,6 +362,8 @@ static void update_search(struct pane *p safe, struct pane *focus safe,
        call("view:changed", focus);
        call("Mode:set-mode", focus, 0, NULL, ":History-search");
        m = mark_at_point(hi->history, NULL, MARK_UNGROUPED);
+       /* Alway search backwards from the end-of-line of last match */
+       call("doc:EOL", hi->history, 1, m);
        ret = call("text-search", hi->history, 1, m, buf_final(&hi->search),
                   hi->search_back);
        if (ret <= 0) {
@@ -369,6 +371,7 @@ static void update_search(struct pane *p safe, struct pane *focus safe,
                mark_free(m);
                return;
        }
+       /* Leave point at start-of-line */
        call("doc:EOL", hi->history, -1, m);
        call("Move-to", hi->history, 0, m);
        mark_free(m);