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

fix mail view search hit scrolling #485

Closed frasertweedale closed 1 year ago

frasertweedale commented 1 year ago

"Next search hit" scrolling in mail view is busted. The main issue is that we were scrolling to line n where n is the search hit number, rather of the line number of the search hit. Reference field _2 instead of _1 to resolve this issue.

A secondary issue is scrolling did not account for inter-paragraph padding. As a result, the scroll point diverges from the search hit at a rate of one line per paragraph. With sufficiently many paragraphs the search hit is not in the viewport. To resolve this issue, eliminate the whole [Paragraph] type. Use a flat [Line] instead.

Also eliminate the "line number" field from the Line data type. Instead, use an indexed traversal to reveal the line number when searching for occurrences of the search string. This change further simplifies MailBody construction and avoids storing unnecessary data.

Fixes: https://github.com/purebred-mua/purebred/issues/448

romanofski commented 1 year ago

Aaah sweet. Very nice!! Thank you!