WIP: Compiling, many warnings, haven't tested
This commit is contained in:
parent
25ad635577
commit
b89c4e06be
4 changed files with 34 additions and 32 deletions
|
@ -388,6 +388,7 @@ impl AsyncAppContext {
|
|||
self.update_window(window_id, |cx| cx.activate_window());
|
||||
}
|
||||
|
||||
// TODO: Can we eliminate this method and move it to WindowContext then call it with update_window?s
|
||||
pub fn prompt(
|
||||
&mut self,
|
||||
window_id: usize,
|
||||
|
|
|
@ -841,7 +841,7 @@ impl<'a: 'b, 'b> WindowContext<'a, 'b> {
|
|||
self.window.platform_window.zoom();
|
||||
}
|
||||
|
||||
pub fn toggle_window_full_screen(&self) {
|
||||
pub fn toggle_full_screen(&self) {
|
||||
self.window.platform_window.toggle_full_screen();
|
||||
}
|
||||
|
||||
|
|
|
@ -1943,7 +1943,8 @@ mod tests {
|
|||
let mut result = Vec::new();
|
||||
let mut project_entries = HashSet::new();
|
||||
let mut has_editor = false;
|
||||
cx.render(panel, |panel, cx| {
|
||||
|
||||
panel.update(cx, |panel, cx| {
|
||||
panel.for_each_visible_entry(range, cx, |project_entry, details, _| {
|
||||
if details.is_editing {
|
||||
assert!(!has_editor, "duplicate editor entry");
|
||||
|
|
|
@ -105,7 +105,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::AppContext) {
|
|||
.titlebar_item()
|
||||
.and_then(|item| item.downcast::<CollabTitlebarItem>())
|
||||
{
|
||||
cx.as_mut().defer(move |cx| {
|
||||
cx.defer(move |_, cx| {
|
||||
item.update(cx, |item, cx| {
|
||||
item.toggle_contacts_popover(&Default::default(), cx);
|
||||
});
|
||||
|
@ -380,19 +380,20 @@ fn restart(_: &Restart, cx: &mut gpui::AppContext) {
|
|||
let should_confirm = cx.global::<Settings>().confirm_quit;
|
||||
cx.spawn(|mut cx| async move {
|
||||
if let (true, Some(workspace)) = (should_confirm, workspaces.first()) {
|
||||
let answer = cx
|
||||
.prompt(
|
||||
let answer = cx.prompt(
|
||||
workspace.window_id(),
|
||||
PromptLevel::Info,
|
||||
"Are you sure you want to restart?",
|
||||
&["Restart", "Cancel"],
|
||||
)
|
||||
.next()
|
||||
.await;
|
||||
);
|
||||
|
||||
if let Some(mut answer) = answer {
|
||||
let answer = answer.next().await;
|
||||
if answer != Some(0) {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the user cancels any save prompt, then keep the app open.
|
||||
for workspace in workspaces {
|
||||
|
@ -424,19 +425,20 @@ fn quit(_: &Quit, cx: &mut gpui::AppContext) {
|
|||
let should_confirm = cx.global::<Settings>().confirm_quit;
|
||||
cx.spawn(|mut cx| async move {
|
||||
if let (true, Some(workspace)) = (should_confirm, workspaces.first()) {
|
||||
let answer = cx
|
||||
.prompt(
|
||||
let answer = cx.prompt(
|
||||
workspace.window_id(),
|
||||
PromptLevel::Info,
|
||||
"Are you sure you want to quit?",
|
||||
&["Quit", "Cancel"],
|
||||
)
|
||||
.next()
|
||||
.await;
|
||||
);
|
||||
|
||||
if let Some(mut answer) = answer {
|
||||
let answer = answer.next().await;
|
||||
if answer != Some(0) {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the user cancels any save prompt, then keep the app open.
|
||||
for workspace in workspaces {
|
||||
|
@ -712,7 +714,7 @@ mod tests {
|
|||
.await;
|
||||
assert_eq!(cx.window_ids().len(), 1);
|
||||
let workspace_1 = cx
|
||||
.root_view(cx.window_ids()[0])
|
||||
.read_window(cx.window_ids()[0], |cx| cx.root_view().clone())
|
||||
.unwrap()
|
||||
.downcast::<Workspace>()
|
||||
.unwrap();
|
||||
|
@ -746,9 +748,8 @@ mod tests {
|
|||
.await;
|
||||
assert_eq!(cx.window_ids().len(), 2);
|
||||
let workspace_1 = cx
|
||||
.root_view(window_id)
|
||||
.read_window(window_id, |cx| cx.root_view().clone())
|
||||
.unwrap()
|
||||
.clone()
|
||||
.downcast::<Workspace>()
|
||||
.unwrap();
|
||||
workspace_1.read_with(cx, |workspace, cx| {
|
||||
|
@ -779,9 +780,8 @@ mod tests {
|
|||
|
||||
// When opening the workspace, the window is not in a edited state.
|
||||
let workspace = cx
|
||||
.root_view(cx.window_ids()[0])
|
||||
.read_window(cx.window_ids()[0], |cx| cx.root_view().clone())
|
||||
.unwrap()
|
||||
.clone()
|
||||
.downcast::<Workspace>()
|
||||
.unwrap();
|
||||
let editor = workspace.read_with(cx, |workspace, cx| {
|
||||
|
@ -851,11 +851,11 @@ mod tests {
|
|||
|
||||
let window_id = *cx.window_ids().first().unwrap();
|
||||
let workspace = cx
|
||||
.root_view(window_id)
|
||||
.read_window(window_id, |cx| cx.root_view().clone())
|
||||
.unwrap()
|
||||
.clone()
|
||||
.downcast::<Workspace>()
|
||||
.unwrap();
|
||||
|
||||
let editor = workspace.update(cx, |workspace, cx| {
|
||||
workspace
|
||||
.active_item(cx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue