Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hint position test, README entry about ligatures #161

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ I was curious to know if this was possible to be written in [Rust](https://www.r

## Troubleshooting

> `tmux-thumbs` isn't as fast as expected

`tmux-thumbs` must work lighting fast. If you are facing a slow performance capturing the screen hints try to configure Tmux with these settings:

```
Expand All @@ -511,15 +513,23 @@ set -g visual-silence on

You can read a bit more about this issue here: https://github.com/fcsonline/tmux-thumbs/issues/88

Every time I use `tmux-thumbs`, dead panes are created. Just review if you have
this setting on:
> Every time I use `tmux-thumbs`, dead panes are created.

Just review if you have this setting on:

```
set -g remain-on-exit on
```

You can read a bit more about this issue here: https://github.com/fcsonline/tmux-thumbs/issues/84

> Sometimes I see the hints showing up in the wrong starting location.

This is likely because the lines with the incorrectly-positioned hints have ligatures. Many CLI utilities
and prompt themes have ligatures.

You can read a bit more about this issue here: https://github.com/fcsonline/tmux-thumbs/issues/158 https://github.com/fcsonline/tmux-thumbs/pull/161

## Donations

If you appreciate all the job done in this project, a small donation is always welcome:
Expand Down
18 changes: 18 additions & 0 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,4 +468,22 @@ mod tests {
assert_eq!(results.get(7).unwrap().text.clone(), "8888");
assert_eq!(results.get(8).unwrap().text.clone(), "https://crates.io/23456/fd70b569");
}

#[test]
fn hint_positioning() {
// first line contains two matched strings, second line has a prefix, third line has a ligature
let lines = split("20240913-lorem-ipsum 10240913-lorem-ipsum-0\n-20240913-lorem-ipsum-1\n↳20240913-lorem-ipsum-2");
let custom = [].to_vec();
let results = State::new(&lines, "abcd", &custom).matches(false, true);

assert_eq!(results.get(0).unwrap().x.clone(), 0);
assert_eq!(results.get(0).unwrap().y.clone(), 0);
assert_eq!(results.get(1).unwrap().x.clone(), 21);
assert_eq!(results.get(1).unwrap().y.clone(), 0);
assert_eq!(results.get(2).unwrap().x.clone(), 1);
assert_eq!(results.get(2).unwrap().y.clone(), 1);
// regex matching can't be aware of ligatures
assert_eq!(results.get(3).unwrap().x.clone(), 3);
assert_eq!(results.get(3).unwrap().y.clone(), 2);
}
}