Fix: highlighting was a bit too intense with new 'at'

This commit is contained in:
2026-03-20 23:43:54 +01:00
parent f020b5a172
commit e26d5e2958

View File

@@ -1,4 +1,4 @@
use std::collections::HashSet; use std::collections::{HashMap, HashSet};
use std::sync::LazyLock; use std::sync::LazyLock;
use ratatui::style::{Modifier, Style}; use ratatui::style::{Modifier, Style};
@@ -220,6 +220,12 @@ pub fn highlight_line_with_runtime(
let theme = theme::get(); let theme = theme::get();
let annotation_style = Style::default().fg(theme.ui.text_dim); let annotation_style = Style::default().fg(theme.ui.text_dim);
// Keep only the last resolved value per span (at-loops produce one per iteration)
let mut last_resolved: HashMap<u32, &str> = HashMap::new();
for (span, display) in resolved {
last_resolved.insert(span.start, display.as_str());
}
for token in &tokens { for token in &tokens {
if token.start > last_end { if token.start > last_end {
result.push((gap_style, line[last_end..token.start].to_string(), false)); result.push((gap_style, line[last_end..token.start].to_string(), false));
@@ -244,10 +250,8 @@ pub fn highlight_line_with_runtime(
result.push((style, line[token.start..token.end].to_string(), false)); result.push((style, line[token.start..token.end].to_string(), false));
for (span, display) in resolved { if let Some(display) = last_resolved.get(&(token.start as u32)) {
if token.start == span.start as usize { result.push((annotation_style, format!(" [{display}]"), true));
result.push((annotation_style, format!(" [{display}]"), true));
}
} }
last_end = token.end; last_end = token.end;