From a53d404aa49a95912774b08e3f634b4dae5b05d6 Mon Sep 17 00:00:00 2001 From: Jed Date: Tue, 16 Jun 2026 08:03:46 +0200 Subject: [PATCH] feat: highlight line --- yazi-core/src/highlighter.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/yazi-core/src/highlighter.rs b/yazi-core/src/highlighter.rs index 0082e4d9..00d7cd6f 100644 --- a/yazi-core/src/highlighter.rs +++ b/yazi-core/src/highlighter.rs @@ -1,4 +1,6 @@ use anyhow::{Result, anyhow, bail}; +use ratatui::style; +use ratatui::style::Style; use ratatui::{ layout::Size, text::{Line, Span, Text}, @@ -150,11 +152,10 @@ impl Highlighter { ) -> Result { let Some(syntax) = self.syntax else { bail!("No syntax") }; let h = self.inner.get_or_insert_with(|| HighlightLines::new(syntax, self.theme)); - let s = String::from_utf8_lossy(buf); - tracing::debug!("s {:?}", s); - let line = [Self::to_line_widget(h.highlight_line(&s, self.syntaxes)?)]; + // tracing::debug!("s {:?}", s); + let line = [Self::to_line_widget(h.highlight_line(&s, self.syntaxes)?)]; let mut it = LineIter::parsed(&line, YAZI.preview.tab_size); if let Some(wrap) = YAZI.preview.wrap.into() { it = it.wrapped(wrap, self.size.width); @@ -165,7 +166,14 @@ impl Highlighter { if *i > self.skip + self.size.height as usize { return Ok(false); } else if *i > self.skip { - lines.push(spans.into_static_line()); + let mut static_line = spans.into_static_line(); + if let Some(pos) = position { + if pos.line == *i { + tracing::debug!("Position: {:?}, line: {}", pos, i); + static_line.style = Style::new().bg(style::Color::Red); + } + } + lines.push(static_line); } self.ensure_not_cancelled()?; }