Move debug_elements
to AsyncAppContext
Previously, `debug_elements` was available on `WindowContext`. If that method was called while having a borrow out to a view, it would panic because the view would already have been borrowed. By moving it to an `AsyncAppContext` we ensure the method can't be called while a view is being used.
This commit is contained in:
parent
4c1cba6def
commit
794446bf8b
4 changed files with 23 additions and 20 deletions
|
@ -11,6 +11,7 @@ use collections::VecDeque;
|
|||
pub use editor;
|
||||
use editor::{Editor, MultiBuffer};
|
||||
|
||||
use anyhow::anyhow;
|
||||
use feedback::{
|
||||
feedback_info_text::FeedbackInfoText, submit_feedback_button::SubmitFeedbackButton,
|
||||
};
|
||||
|
@ -215,9 +216,14 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::AppContext) {
|
|||
move |workspace: &mut Workspace, _: &DebugElements, cx: &mut ViewContext<Workspace>| {
|
||||
let app_state = workspace.app_state().clone();
|
||||
let markdown = app_state.languages.language_for_name("JSON");
|
||||
let content = to_string_pretty(&cx.debug_elements()).unwrap();
|
||||
let window_id = cx.window_id();
|
||||
cx.spawn(|workspace, mut cx| async move {
|
||||
let markdown = markdown.await.log_err();
|
||||
let content = to_string_pretty(
|
||||
&cx.debug_elements(window_id)
|
||||
.ok_or_else(|| anyhow!("could not debug elements for {window_id}"))?,
|
||||
)
|
||||
.unwrap();
|
||||
workspace
|
||||
.update(&mut cx, |workspace, cx| {
|
||||
workspace.with_local_workspace(cx, move |workspace, cx| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue