Move debug_elements to AnyWindowHandle
This commit is contained in:
parent
4f10f0ee86
commit
95cd96e4be
2 changed files with 9 additions and 9 deletions
|
@ -344,14 +344,6 @@ impl AsyncAppContext {
|
||||||
self.0.borrow().windows().collect()
|
self.0.borrow().windows().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn debug_elements(&self, window: AnyWindowHandle) -> Option<json::Value> {
|
|
||||||
self.0.borrow().read_window(window, |cx| {
|
|
||||||
let root_view = cx.window.root_view();
|
|
||||||
let root_element = cx.window.rendered_views.get(&root_view.id())?;
|
|
||||||
root_element.debug(cx).log_err()
|
|
||||||
})?
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn dispatch_action(
|
pub fn dispatch_action(
|
||||||
&mut self,
|
&mut self,
|
||||||
window: AnyWindowHandle,
|
window: AnyWindowHandle,
|
||||||
|
@ -4060,6 +4052,14 @@ impl AnyWindowHandle {
|
||||||
self.update(cx, |cx| cx.remove_window())
|
self.update(cx, |cx| cx.remove_window())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn debug_elements<C: BorrowWindowContext>(&self, cx: &C) -> Option<json::Value> {
|
||||||
|
self.read_optional_with(cx, |cx| {
|
||||||
|
let root_view = cx.window.root_view();
|
||||||
|
let root_element = cx.window.rendered_views.get(&root_view.id())?;
|
||||||
|
root_element.debug(cx).log_err()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub fn simulate_activation(&self, cx: &mut TestAppContext) {
|
pub fn simulate_activation(&self, cx: &mut TestAppContext) {
|
||||||
self.update(cx, |cx| {
|
self.update(cx, |cx| {
|
||||||
|
|
|
@ -182,7 +182,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::AppContext) {
|
||||||
let window = cx.window();
|
let window = cx.window();
|
||||||
cx.spawn(|workspace, mut cx| async move {
|
cx.spawn(|workspace, mut cx| async move {
|
||||||
let markdown = markdown.await.log_err();
|
let markdown = markdown.await.log_err();
|
||||||
let content = to_string_pretty(&cx.debug_elements(window).ok_or_else(|| {
|
let content = to_string_pretty(&window.debug_elements(&cx).ok_or_else(|| {
|
||||||
anyhow!("could not debug elements for window {}", window.id())
|
anyhow!("could not debug elements for window {}", window.id())
|
||||||
})?)
|
})?)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue