From 606adc1daaf86e483e47dd0e2d14a3082a5ee382 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 24 Aug 2024 12:19:26 +0200 Subject: [PATCH] Fix build errors --- src/highlight.rs | 8 ++++++-- src/tty/unix.rs | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/highlight.rs b/src/highlight.rs index ef8740893..fa79d7080 100644 --- a/src/highlight.rs +++ b/src/highlight.rs @@ -249,7 +249,11 @@ impl MatchingBracketHighlighter { } } -#[cfg(any(not(feature = "split-highlight"), feature = "anstyle"))] +#[cfg(any( + not(feature = "split-highlight"), + feature = "anstyle", + feature = "ansi-str" +))] impl Highlighter for MatchingBracketHighlighter { #[cfg(all(feature = "split-highlight", not(feature = "ansi-str")))] type Style = anstyle::Style; @@ -264,7 +268,7 @@ impl Highlighter for MatchingBracketHighlighter { if let Some((matching, idx)) = find_matching_bracket(line, pos, bracket) { let mut copy = line.to_owned(); copy.replace_range(idx..=idx, &format!("\x1b[1;34m{}\x1b[0m", matching as char)); - return Owned(copy); + return Cow::Owned(copy); } } Borrowed(line) diff --git a/src/tty/unix.rs b/src/tty/unix.rs index cc8c8d074..0c40ebdd6 100644 --- a/src/tty/unix.rs +++ b/src/tty/unix.rs @@ -27,7 +27,7 @@ use utf8parse::{Parser, Receiver}; use super::{width, Event, RawMode, RawReader, Renderer, Term}; use crate::config::{Behavior, BellStyle, ColorMode, Config}; -use crate::highlight::{Highlighter, Style}; +use crate::highlight::Highlighter; use crate::keys::{KeyCode as K, KeyEvent, KeyEvent as E, Modifiers as M}; use crate::layout::{Layout, Position}; use crate::line_buffer::LineBuffer; @@ -1010,6 +1010,7 @@ impl Renderer for PosixRenderer { self.buffer .push_str(&highlighter.highlight(line, line.pos())); } else { + use crate::highlight::Style; for (style, block) in highlighter.highlight_line(line, line.pos()) { write!(self.buffer, "{}", style.start())?; self.buffer.push_str(block);