Skip to content

Commit

Permalink
Filter out empty locs
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncozens committed Jul 19, 2024
1 parent 93d01a4 commit 997b6d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
18 changes: 5 additions & 13 deletions src/bin/diffenator3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,6 @@ fn main() {
}

// Location-specific tests

// let loc_name: String = if let Some(ref loc) = cli.location {
// let _hack = font_a.set_location(loc);
// let _hack = font_b.set_location(loc);
// loc.clone()
// } else if let Some(ref inst) = cli.instance {
// font_a.set_instance(inst).expect("Couldn't find instance");
// font_b.set_instance(inst).expect("Couldn't find instance");
// inst.clone()
// } else {
// "default".into()
// };

let settings: Vec<Setting> = generate_settings(&cli, &font_a, &font_b);

result.locations = settings
Expand All @@ -145,6 +132,11 @@ fn main() {
})
.collect();

// If there's more than one, filter out the boring ones
if result.locations.len() > 1 {
result.locations.retain(|l| l.is_some());
}

// Report back
if cli.html {
reporters::html::report(
Expand Down
2 changes: 1 addition & 1 deletion src/reporters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct LocationResult {
}

impl LocationResult {
fn is_some(&self) -> bool {
pub fn is_some(&self) -> bool {
self.error.is_some()
|| !self.glyphs.is_empty()
|| (self.words.is_some() && self.words.as_ref().unwrap().is_something())
Expand Down
5 changes: 5 additions & 0 deletions src/templates/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ $(function () {
}
cmapDiff_static_html();
$('[data-toggle="tooltip"]').tooltip()
if (!report["locations"]) {
$("#title").html("<h4 class='mt-2'>No differences found</h4>");
$("#ui-nav").hide();
return;
}

for (var [index, loc] of report["locations"].entries()) {
var loc_nav = $(`<li class="nav-item">
Expand Down

0 comments on commit 997b6d6

Please sign in to comment.