debugger_ui: Show a toast when setting breakpoints fails (#28815)

Release Notes:

- N/A

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Anthony <anthony@zed.dev>
This commit is contained in:
Cole Miller 2025-04-17 18:10:57 -04:00 committed by GitHub
parent 80a2f71d8e
commit 4095011af5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 101 additions and 32 deletions

View file

@ -23,7 +23,7 @@ use futures::{
};
use gpui::{
App, AppContext, AsyncApp, BackgroundExecutor, Context, Entity, EventEmitter, SharedString,
Task,
Task, WeakEntity,
};
use http_client::HttpClient;
use language::{BinaryStatus, LanguageRegistry, LanguageToolchainStore};
@ -320,7 +320,7 @@ impl DapStore {
session.set_ignore_breakpoints(envelope.payload.ignore, cx)
})
} else {
Task::ready(())
Task::ready(HashMap::default())
}
})?
.await;
@ -350,6 +350,7 @@ impl DapStore {
&mut self,
binary: DebugAdapterBinary,
config: DebugTaskDefinition,
worktree: WeakEntity<Worktree>,
parent_session: Option<Entity<Session>>,
cx: &mut Context<Self>,
) -> (SessionId, Task<Result<Entity<Session>>>) {
@ -373,6 +374,7 @@ impl DapStore {
let start_client_task = this.update(cx, |this, cx| {
Session::local(
this.breakpoint_store.clone(),
worktree.clone(),
session_id,
parent_session,
binary,
@ -385,7 +387,7 @@ impl DapStore {
let ret = this
.update(cx, |_, cx| {
create_new_session(session_id, initialized_rx, start_client_task, cx)
create_new_session(session_id, initialized_rx, start_client_task, worktree, cx)
})?
.await;
ret
@ -404,6 +406,16 @@ impl DapStore {
return Task::ready(Err(anyhow!("Session not found")));
};
let Some(worktree) = parent_session
.read(cx)
.as_local()
.map(|local| local.worktree().clone())
else {
return Task::ready(Err(anyhow!(
"Cannot handle start debugging request from remote end"
)));
};
let args = serde_json::from_value::<StartDebuggingRequestArguments>(
request.arguments.unwrap_or_default(),
)
@ -413,7 +425,7 @@ impl DapStore {
binary.request_args = args;
let new_session_task = self
.new_session(binary, config, Some(parent_session.clone()), cx)
.new_session(binary, config, worktree, Some(parent_session.clone()), cx)
.1;
let request_seq = request.seq;
@ -742,6 +754,7 @@ fn create_new_session(
session_id: SessionId,
initialized_rx: oneshot::Receiver<()>,
start_client_task: Task<Result<Entity<Session>, anyhow::Error>>,
worktree: WeakEntity<Worktree>,
cx: &mut Context<DapStore>,
) -> Task<Result<Entity<Session>>> {
let task = cx.spawn(async move |this, cx| {
@ -771,7 +784,7 @@ fn create_new_session(
session
.update(cx, |session, cx| {
session.initialize_sequence(initialized_rx, cx)
session.initialize_sequence(initialized_rx, this.clone(), cx)
})?
.await
};
@ -820,12 +833,13 @@ fn create_new_session(
let task = curr_session.update(cx, |session, cx| session.shutdown(cx));
let worktree = worktree.clone();
cx.spawn(async move |this, cx| {
task.await;
this.update(cx, |this, cx| {
this.sessions.remove(&session_id);
this.new_session(binary, config, None, cx)
this.new_session(binary, config, worktree, None, cx)
})?
.1
.await?;