From aa80485a2489892e649ae8815c4710f12b19bd80 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 4 Oct 2024 19:28:29 -0700 Subject: [PATCH 1/1] Fix hover highlight for relabeled columns --- Changelog | 1 + src/lib.rs | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index d2bc4b4..45ae92a 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ ## [Unreleased] +- Fix hover highlight for relabeled columns ## [0.5.0] - 2024-10-04 - `!label col:new label` to substitute a different label for a column diff --git a/src/lib.rs b/src/lib.rs index 70dfb52..c1a4761 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -313,7 +313,12 @@ fn render_instances(instances: &[Option]) -> HTML { fn render_cell(config: &Config, col: &str, row: &mut Row) -> HTML { let row_label = HTML::escape(row.label.as_ref()); - let col_label = HTML::escape(col); + let col_label = HTML::escape( + config + .substitute_labels + .get(col) + .map_or(col, std::string::String::as_str), + ); let instances: Option<&Vec>> = row.entries.get(col); let is_empty = match instances { None => true, @@ -975,6 +980,25 @@ mod tests { ), HTML::from( r#"nope +"# + ) + ); + assert_eq!( + render_row( + &Config { + column_threshold: 0, + static_columns: vec![], + hidden_columns: HashSet::new(), + substitute_labels: HashMap::from([("foo".to_owned(), "bar".to_owned())]), + }, + &["foo".to_owned()], + &mut Rowlike::Row(Row { + label: "nope".to_owned(), + entries: HashMap::from([("foo".to_owned(), vec![None])]), + }) + ), + HTML::from( + r#"nope𝍷 "# ) ); -- 2.44.1