Skip to content

Commit

Permalink
fix issue w/ app menu not showing up correctly in macos
Browse files Browse the repository at this point in the history
  • Loading branch information
a5huynh committed Feb 6, 2023
1 parent 88b150e commit 541dea0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
14 changes: 10 additions & 4 deletions crates/shared/src/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ pub fn regex_for_domain(domain: &str) -> String {
}

pub fn regex_for_prefix(prefix: &str) -> String {
let prefix = regex::escape(prefix);
if prefix.ends_with('$') {
return format!("^{prefix}");
let escaped = regex::escape(prefix.strip_suffix('$').unwrap());
format!("^{escaped}$")
} else {
let escaped = regex::escape(prefix);
format!("^{escaped}.*")
}

format!("^{prefix}.*")
}

/// Convert a robots.txt rule into a proper regex string
Expand Down Expand Up @@ -134,5 +135,10 @@ mod test {
] {
assert!(!regex.is_match(test));
}

let prefix = "https://en.wikipedia.org/wiki/\'($";
let regex = Regex::new(&regex_for_prefix(prefix)).unwrap();
dbg!(&regex);
assert!(regex.is_match("https://en.wikipedia.org/wiki/\'("));
}
}
2 changes: 2 additions & 0 deletions crates/spyglass/src/api/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,8 @@ mod test {
.await
.expect("Unable to find indexed docs");
assert_eq!(indexed.len(), 0);
// Add a small delay so that the documents can be properly committed
std::thread::sleep(std::time::Duration::from_millis(500));
assert_eq!(state.index.reader.searcher().num_docs(), 0);
}
}
6 changes: 3 additions & 3 deletions crates/tauri/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ pub fn get_tray_menu(ctx: &Context<EmbeddedAssets>, config: &Config) -> SystemTr
}

pub fn get_app_menu(ctx: &Context<EmbeddedAssets>) -> Menu {
if cfg!(target_os = "linux") {
return Menu::new();
}
#[cfg(target_os = "linux")]
return Menu::new();

#[cfg(not(target_os = "linux"))]
Menu::new().add_submenu(Submenu::new(
&ctx.package_info().name,
Menu::new()
Expand Down

0 comments on commit 541dea0

Please sign in to comment.