Assume at least 8 colors (#565)

This commit is contained in:
trevyn 2021-03-20 09:14:40 +04:00 committed by GitHub
parent 7cf597f9bb
commit 85f6372c68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,6 +74,7 @@ fn find_closest_pair(pair: ColorPair, max_colors: i16) -> (i16, i16) {
/// If `max_colors` is less than 256 (like 8 or 16), the color will be
/// downgraded to the closest one available.
fn find_closest(color: Color, max_colors: i16) -> i16 {
let max_colors = std::cmp::max(max_colors, 8);
match color {
Color::TerminalDefault => -1,
Color::Dark(BaseColor::Black) => 0,