Skip to content

Cannot clear highlights in bat::PrettyPrinter instance #1919

Closed
@rhysd

Description

@rhysd

Describe the bug you encountered:

Let's say we have the following code:

use bat::PrettyPrinter;

let targets: (PathBuf, Vec<(usize, usize)>) = vec![];

let mut pp = PrettyPrinter::new();
for (path, ranges) in targets.iter() {
    pp.input_file(path);
    for (start, end) in ranges.iter() {
        pp.highlight_range(*start, *end);
    }

    // This clears inputs, but does not clear highlights
    pp.print().unwrap();
}

Since there are multiple files with different highlight ranges, I want to print each files with different ranges. However, currently there is no way to clear highlights in bat::PrettyPrinter instance.

Creating bat::PrettyPrinter instance for each file is an option. However it is much slower because bat::PrettyPrinter::new deserializes binary assets and it is time consuming.

What did you expect to happen instead?

I'd like bat::PrettyPrinter to provide some API to clear highlights.

How did you install bat?

[dependencies]
bat = { version = "0.18.3", default-features = false }

in my project's Cargo.toml.


bat version and environment

  • bat: 0.18.3
  • OS: macOS 10.15
  • Rust: 1.56

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions