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

SkimItem documentation claims the matcher runs against text() which is not the case #344

Closed
wucke13 opened this issue Sep 17, 2020 · 0 comments
Labels

Comments

@wucke13
Copy link
Contributor

wucke13 commented Sep 17, 2020

The documentation claims that the matcher runs against text():

the string to be used for matching(without color)

(Please notice also as well that the should be capitalized and that a space should be placed before the opening parantheses)

Thus I would expect, that an item which returns some pattern in text() can be matched by this pattern, regardless of what display() returns. Considering this minimal example, this expectation is not fulfilled. Entering x yields zero results.

use skim::prelude::*;

struct MyItem {}

impl SkimItem for MyItem {
    fn display(&self) -> Cow<AnsiString> {
        Cow::Owned(AnsiString::parse("abcdef"))
    }

    fn text(&self) -> Cow<str> {
        Cow::Owned(String::from("abcdef xyz"))
    }
}

fn main() {
    let options = SkimOptionsBuilder::default().build().unwrap();

    let (tx_item, rx_item): (SkimItemSender, SkimItemReceiver) = unbounded();
    let _ = tx_item.send(Arc::new(MyItem {}));
    drop(tx_item); // so that skim could know when to stop waiting for more items.

    let selected_items = Skim::run_with(&options, Some(rx_item))
        .map(|out| out.selected_items)
        .unwrap_or_else(|| Vec::new());
}
@lotabout lotabout added the bug label Sep 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants