debugger: Fix module list getting queried when not shown (#32761)
Closes #ISSUE Release Notes: - N/A
This commit is contained in:
parent
a5ceef35fa
commit
0433b8859d
1 changed files with 12 additions and 9 deletions
|
@ -20,7 +20,7 @@ pub struct ModuleList {
|
||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
scrollbar_state: ScrollbarState,
|
scrollbar_state: ScrollbarState,
|
||||||
entries: Vec<Module>,
|
entries: Vec<Module>,
|
||||||
_rebuild_task: Task<()>,
|
_rebuild_task: Option<Task<()>>,
|
||||||
_subscription: Subscription,
|
_subscription: Subscription,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,14 +34,16 @@ impl ModuleList {
|
||||||
|
|
||||||
let _subscription = cx.subscribe(&session, |this, _, event, cx| match event {
|
let _subscription = cx.subscribe(&session, |this, _, event, cx| match event {
|
||||||
SessionEvent::Stopped(_) | SessionEvent::Modules => {
|
SessionEvent::Stopped(_) | SessionEvent::Modules => {
|
||||||
this.schedule_rebuild(cx);
|
if this._rebuild_task.is_some() {
|
||||||
|
this.schedule_rebuild(cx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
});
|
});
|
||||||
|
|
||||||
let scroll_handle = UniformListScrollHandle::new();
|
let scroll_handle = UniformListScrollHandle::new();
|
||||||
|
|
||||||
let mut this = Self {
|
Self {
|
||||||
scrollbar_state: ScrollbarState::new(scroll_handle.clone()),
|
scrollbar_state: ScrollbarState::new(scroll_handle.clone()),
|
||||||
scroll_handle,
|
scroll_handle,
|
||||||
session,
|
session,
|
||||||
|
@ -50,14 +52,12 @@ impl ModuleList {
|
||||||
entries: Vec::new(),
|
entries: Vec::new(),
|
||||||
selected_ix: None,
|
selected_ix: None,
|
||||||
_subscription,
|
_subscription,
|
||||||
_rebuild_task: Task::ready(()),
|
_rebuild_task: None,
|
||||||
};
|
}
|
||||||
this.schedule_rebuild(cx);
|
|
||||||
this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn schedule_rebuild(&mut self, cx: &mut Context<Self>) {
|
fn schedule_rebuild(&mut self, cx: &mut Context<Self>) {
|
||||||
self._rebuild_task = cx.spawn(async move |this, cx| {
|
self._rebuild_task = Some(cx.spawn(async move |this, cx| {
|
||||||
this.update(cx, |this, cx| {
|
this.update(cx, |this, cx| {
|
||||||
let modules = this
|
let modules = this
|
||||||
.session
|
.session
|
||||||
|
@ -66,7 +66,7 @@ impl ModuleList {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_module(&mut self, path: Arc<Path>, window: &mut Window, cx: &mut Context<Self>) {
|
fn open_module(&mut self, path: Arc<Path>, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
|
@ -300,6 +300,9 @@ impl Focusable for ModuleList {
|
||||||
|
|
||||||
impl Render for ModuleList {
|
impl Render for ModuleList {
|
||||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
|
if self._rebuild_task.is_none() {
|
||||||
|
self.schedule_rebuild(cx);
|
||||||
|
}
|
||||||
div()
|
div()
|
||||||
.track_focus(&self.focus_handle)
|
.track_focus(&self.focus_handle)
|
||||||
.on_action(cx.listener(Self::select_last))
|
.on_action(cx.listener(Self::select_last))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue