Fix: highlighting was a bit too intense with new 'at'
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use std::collections::HashSet;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use ratatui::style::{Modifier, Style};
|
||||
@@ -220,6 +220,12 @@ pub fn highlight_line_with_runtime(
|
||||
let theme = theme::get();
|
||||
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 {
|
||||
if token.start > last_end {
|
||||
result.push((gap_style, line[last_end..token.start].to_string(), false));
|
||||
@@ -244,11 +250,9 @@ pub fn highlight_line_with_runtime(
|
||||
|
||||
result.push((style, line[token.start..token.end].to_string(), false));
|
||||
|
||||
for (span, display) in resolved {
|
||||
if token.start == span.start as usize {
|
||||
if let Some(display) = last_resolved.get(&(token.start as u32)) {
|
||||
result.push((annotation_style, format!(" [{display}]"), true));
|
||||
}
|
||||
}
|
||||
|
||||
last_end = token.end;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user