Skip to content

Commit b5c7aad

Browse files
committed
with_new_window_req_handler
1 parent 5cc8696 commit b5c7aad

3 files changed

Lines changed: 56 additions & 27 deletions

File tree

Cargo.lock

Lines changed: 45 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ gpui = { git = "https://github.com/zed-industries/zed" }
88
gpui-component = { git = "https://github.com/longbridge/gpui-component", rev = "2a3c297d7635146958ff147054016e08f16ec9b4" }
99
gpui-wry = { git = "https://github.com/longbridge/gpui-component", rev = "2a3c297d7635146958ff147054016e08f16ec9b4"}
1010
wry = { version = "0.53.3", package = "lb-wry" }
11-
anyhow = "1.0.95"
11+
anyhow = "1.0.102"
1212
async-trait = "0.1.85"
1313
directories = "6.0.0"
1414
tracing = "0.1.41"
@@ -30,9 +30,10 @@ winsplit = "0.1.0"
3030
rust-embed = { version = "8", features = ["interpolate-folder-path"] }
3131
notify-rust = "4.11.7"
3232
async-compat = "0.2.5"
33-
futures = "0.3.31"
34-
reqwest = "0.13.1"
33+
futures = "0.3.32"
34+
reqwest = "0.13.2"
3535
windows-sys = { version = "0.61.2", features = ["Win32_Foundation", "Win32_System_Diagnostics_Debug", "Win32_System_Kernel"] }
36+
webbrowser = "1.1.0"
3637

3738
[profile.release]
3839
strip = true # Automatically strip symbols from the binary.

src/native/components/webview.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ impl SimpleWebView {
1111
let webview = cx.new(|cx| {
1212
let mut builder = wry::WebViewBuilder::new()
1313
.with_user_agent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36")
14-
.with_transparent(true);
14+
.with_transparent(true).with_new_window_req_handler(|url, _| {
15+
tracing::info!(%url, "Opening URL in external browser");
16+
if let Err(e) = webbrowser::open(&url) {
17+
tracing::error!(%e, "Failed to open URL in browser");
18+
}
19+
wry::NewWindowResponse::Deny
20+
});
1521

1622
builder = if crate::utils::url::is_url(source) {
1723
tracing::debug!(url = %source, "Loading URL in webview");

0 commit comments

Comments
 (0)