AMythicDev / minus

An asynchronous, runtime data feedable terminal paging library for Rust
https://crates.io/crates/minus/
Apache License 2.0
322 stars 23 forks source link

Accurate Search Highlights #109

Closed AMythicDev closed 1 year ago

AMythicDev commented 1 year ago

Right now minus uses a highlighting technique while searching where first removes all ANSI escape sequences from the text data and then a search and then searches the entire text. If a match is found, it places an ANSI INVERT sequence right before the match and an ANSI NORMAL sequence right after the match. Then it places all the escape sequences that the original text had into the right position.

Now where this goes wrong is if a match has escape sequence inside it, minus does not place it at that position. This approach brings a more consistent highlighting throughout and makes the text look less funky at the cost of some inaccuracies. But sometimes this cost is unaffordable hence this PR.

With this we plan to further improve the search highlighting technique to where a user has two options:-