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

Terminal colors are not restored after Skim::run_with returns #533

Open
tyilo opened this issue Jun 17, 2023 · 2 comments
Open

Terminal colors are not restored after Skim::run_with returns #533

tyilo opened this issue Jun 17, 2023 · 2 comments

Comments

@tyilo
Copy link

tyilo commented Jun 17, 2023

Running the example Rust code from the README and choosing the bbbb option using arrow up and enter the ouput is as follows:

image

You can see that bbbb output is not shown in the default color of my terminal.

This doesn't happen if option aaaaa is selected by just pressing enter:

image

Screencast.2023-06-17.13.39.00.webm
@LoricAndre
Copy link
Contributor

I was not able to reproduce this in the latest version, please reopen with reproduction steps if the issue is still present

@tyilo
Copy link
Author

tyilo commented Dec 17, 2024

This still happens, using the following code and skim v0.15.5:

extern crate skim;
use skim::prelude::*;
use std::io::Cursor;

pub fn main() {
    let options = SkimOptionsBuilder::default()
        .height("50%".to_string())
        .multi(true)
        .build()
        .unwrap();

    let input = "aaaaa\nbbbb\nccc".to_string();

    // `SkimItemReader` is a helper to turn any `BufRead` into a stream of `SkimItem`
    // `SkimItem` was implemented for `AsRef<str>` by default
    let item_reader = SkimItemReader::default();
    let items = item_reader.of_bufread(Cursor::new(input));

    // `run_with` would read and show items from the stream
    let selected_items = Skim::run_with(&options, Some(items))
        .map(|out| out.selected_items)
        .unwrap_or_else(|| Vec::new());

    for item in selected_items.iter() {
        print!("{}{}", item.output(), "\n");
    }
}

The code was taken from the current README, however it does not compile without changing .height(Some("50%")) to .height("50%".to_string())

@LoricAndre LoricAndre reopened this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants