purebred-mua / purebred

A terminal based mail user agent based on notmuch
GNU Affero General Public License v3.0
139 stars 19 forks source link

mail body search: refactors, add "previous match" action #487

Closed frasertweedale closed 2 years ago

frasertweedale commented 2 years ago
9206083 (Fraser Tweedale, 9 minutes ago)
   add scrollPreviousMatch action

   Alongside the existing "scroll to next match" action, add the
   `scrollPreviousMatch` action.  Bind `'N'` to this action in the default
   keybindings.

   Also rename `scrollNextWord` to `scrollNextMatch` which better expresses
   the real behaviour (a search term can match part of a term or span word
   boundaries).

d68f2f2 (Fraser Tweedale, 49 minutes ago)
   further simplify mail body search

   The remains a considerable dupliation of data within our implementation of
   mail body search.  In particular, `ScrollStep` duplicates `Match` values
   from `Line`.

   Refactor the implementation in the following ways:

   - Promote the `[Match]` from the `Line` data type to the `MailBody`
    type (as a single, combined list)

   - Remove the `Line` data type, replacing it with bare `Text`

   - Replace the `FocusRing ScrollStep` with an `Int` that records the
    current search hit index.

   - Extract the "scroll to search index" behaviour as a helper action.
    It modifies the search index, wrapping if necessary.  Update
    relevant actions to use the new method.

   - Clean up the rendering function