mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 02:46:43 +00:00
Merge pull request #2095 from zed-industries/fix-crash-when-opening-feedback-while-in-call
Fix crash when opening feedback while in call
This commit is contained in:
commit
a4d9d6c750
3 changed files with 31 additions and 29 deletions
|
@ -5,7 +5,7 @@ mod system_specs;
|
||||||
use gpui::{actions, impl_actions, ClipboardItem, ViewContext};
|
use gpui::{actions, impl_actions, ClipboardItem, ViewContext};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use system_specs::SystemSpecs;
|
use system_specs::SystemSpecs;
|
||||||
use workspace::Workspace;
|
use workspace::{AppState, Workspace};
|
||||||
|
|
||||||
#[derive(Deserialize, Clone, PartialEq)]
|
#[derive(Deserialize, Clone, PartialEq)]
|
||||||
pub struct OpenBrowser {
|
pub struct OpenBrowser {
|
||||||
|
@ -19,8 +19,8 @@ actions!(
|
||||||
[CopySystemSpecsIntoClipboard, FileBugReport, RequestFeature,]
|
[CopySystemSpecsIntoClipboard, FileBugReport, RequestFeature,]
|
||||||
);
|
);
|
||||||
|
|
||||||
pub fn init(cx: &mut gpui::MutableAppContext) {
|
pub fn init(app_state: Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
||||||
feedback_editor::init(cx);
|
feedback_editor::init(app_state, cx);
|
||||||
|
|
||||||
cx.add_global_action(move |action: &OpenBrowser, cx| cx.platform().open_url(&action.url));
|
cx.add_global_action(move |action: &OpenBrowser, cx| cx.platform().open_url(&action.url));
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ use settings::Settings;
|
||||||
use workspace::{
|
use workspace::{
|
||||||
item::{Item, ItemHandle},
|
item::{Item, ItemHandle},
|
||||||
searchable::{SearchableItem, SearchableItemHandle},
|
searchable::{SearchableItem, SearchableItemHandle},
|
||||||
StatusItemView, Workspace,
|
AppState, StatusItemView, Workspace,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::system_specs::SystemSpecs;
|
use crate::system_specs::SystemSpecs;
|
||||||
|
@ -43,8 +43,12 @@ const FEEDBACK_SUBMISSION_ERROR_TEXT: &str =
|
||||||
|
|
||||||
actions!(feedback, [SubmitFeedback, GiveFeedback, DeployFeedback]);
|
actions!(feedback, [SubmitFeedback, GiveFeedback, DeployFeedback]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
||||||
cx.add_action(FeedbackEditor::deploy);
|
cx.add_action({
|
||||||
|
move |workspace: &mut Workspace, _: &GiveFeedback, cx: &mut ViewContext<Workspace>| {
|
||||||
|
FeedbackEditor::deploy(workspace, app_state.clone(), cx);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FeedbackButton;
|
pub struct FeedbackButton;
|
||||||
|
@ -98,7 +102,7 @@ struct FeedbackEditor {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FeedbackEditor {
|
impl FeedbackEditor {
|
||||||
fn new_with_buffer(
|
fn new(
|
||||||
project: ModelHandle<Project>,
|
project: ModelHandle<Project>,
|
||||||
buffer: ModelHandle<Buffer>,
|
buffer: ModelHandle<Buffer>,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
|
@ -116,18 +120,6 @@ impl FeedbackEditor {
|
||||||
Self { editor, project }
|
Self { editor, project }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(project: ModelHandle<Project>, cx: &mut ViewContext<Self>) -> Self {
|
|
||||||
let markdown_language = project.read(cx).languages().language_for_name("Markdown");
|
|
||||||
|
|
||||||
let buffer = project
|
|
||||||
.update(cx, |project, cx| {
|
|
||||||
project.create_buffer("", markdown_language, cx)
|
|
||||||
})
|
|
||||||
.expect("creating buffers on a local workspace always succeeds");
|
|
||||||
|
|
||||||
Self::new_with_buffer(project, buffer, cx)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_save(
|
fn handle_save(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: ModelHandle<Project>,
|
_: ModelHandle<Project>,
|
||||||
|
@ -236,10 +228,24 @@ impl FeedbackEditor {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FeedbackEditor {
|
impl FeedbackEditor {
|
||||||
pub fn deploy(workspace: &mut Workspace, _: &GiveFeedback, cx: &mut ViewContext<Workspace>) {
|
pub fn deploy(
|
||||||
let feedback_editor =
|
workspace: &mut Workspace,
|
||||||
cx.add_view(|cx| FeedbackEditor::new(workspace.project().clone(), cx));
|
app_state: Arc<AppState>,
|
||||||
workspace.add_item(Box::new(feedback_editor), cx);
|
cx: &mut ViewContext<Workspace>,
|
||||||
|
) {
|
||||||
|
workspace
|
||||||
|
.with_local_workspace(&app_state, cx, |workspace, cx| {
|
||||||
|
let project = workspace.project().clone();
|
||||||
|
let markdown_language = project.read(cx).languages().language_for_name("Markdown");
|
||||||
|
let buffer = project
|
||||||
|
.update(cx, |project, cx| {
|
||||||
|
project.create_buffer("", markdown_language, cx)
|
||||||
|
})
|
||||||
|
.expect("creating buffers on a local workspace always succeeds");
|
||||||
|
let feedback_editor = cx.add_view(|cx| FeedbackEditor::new(project, buffer, cx));
|
||||||
|
workspace.add_item(Box::new(feedback_editor), cx);
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,11 +340,7 @@ impl Item for FeedbackEditor {
|
||||||
.as_singleton()
|
.as_singleton()
|
||||||
.expect("Feedback buffer is only ever singleton");
|
.expect("Feedback buffer is only ever singleton");
|
||||||
|
|
||||||
Some(Self::new_with_buffer(
|
Some(Self::new(self.project.clone(), buffer.clone(), cx))
|
||||||
self.project.clone(),
|
|
||||||
buffer.clone(),
|
|
||||||
cx,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialized_item_kind() -> Option<&'static str> {
|
fn serialized_item_kind() -> Option<&'static str> {
|
||||||
|
|
|
@ -135,7 +135,6 @@ fn main() {
|
||||||
client::init(client.clone(), cx);
|
client::init(client.clone(), cx);
|
||||||
command_palette::init(cx);
|
command_palette::init(cx);
|
||||||
editor::init(cx);
|
editor::init(cx);
|
||||||
feedback::init(cx);
|
|
||||||
go_to_line::init(cx);
|
go_to_line::init(cx);
|
||||||
file_finder::init(cx);
|
file_finder::init(cx);
|
||||||
outline::init(cx);
|
outline::init(cx);
|
||||||
|
@ -183,6 +182,7 @@ fn main() {
|
||||||
theme_selector::init(app_state.clone(), cx);
|
theme_selector::init(app_state.clone(), cx);
|
||||||
zed::init(&app_state, cx);
|
zed::init(&app_state, cx);
|
||||||
collab_ui::init(app_state.clone(), cx);
|
collab_ui::init(app_state.clone(), cx);
|
||||||
|
feedback::init(app_state.clone(), cx);
|
||||||
|
|
||||||
cx.set_menus(menus::menus());
|
cx.set_menus(menus::menus());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue