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());
|
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(
|
pub fn prompt(
|
||||||
&mut self,
|
&mut self,
|
||||||
window_id: usize,
|
window_id: usize,
|
||||||
|
|
|
@ -841,7 +841,7 @@ impl<'a: 'b, 'b> WindowContext<'a, 'b> {
|
||||||
self.window.platform_window.zoom();
|
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();
|
self.window.platform_window.toggle_full_screen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1943,7 +1943,8 @@ mod tests {
|
||||||
let mut result = Vec::new();
|
let mut result = Vec::new();
|
||||||
let mut project_entries = HashSet::new();
|
let mut project_entries = HashSet::new();
|
||||||
let mut has_editor = false;
|
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, _| {
|
panel.for_each_visible_entry(range, cx, |project_entry, details, _| {
|
||||||
if details.is_editing {
|
if details.is_editing {
|
||||||
assert!(!has_editor, "duplicate editor entry");
|
assert!(!has_editor, "duplicate editor entry");
|
||||||
|
|
|
@ -105,7 +105,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::AppContext) {
|
||||||
.titlebar_item()
|
.titlebar_item()
|
||||||
.and_then(|item| item.downcast::<CollabTitlebarItem>())
|
.and_then(|item| item.downcast::<CollabTitlebarItem>())
|
||||||
{
|
{
|
||||||
cx.as_mut().defer(move |cx| {
|
cx.defer(move |_, cx| {
|
||||||
item.update(cx, |item, cx| {
|
item.update(cx, |item, cx| {
|
||||||
item.toggle_contacts_popover(&Default::default(), cx);
|
item.toggle_contacts_popover(&Default::default(), cx);
|
||||||
});
|
});
|
||||||
|
@ -380,17 +380,18 @@ fn restart(_: &Restart, cx: &mut gpui::AppContext) {
|
||||||
let should_confirm = cx.global::<Settings>().confirm_quit;
|
let should_confirm = cx.global::<Settings>().confirm_quit;
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
if let (true, Some(workspace)) = (should_confirm, workspaces.first()) {
|
if let (true, Some(workspace)) = (should_confirm, workspaces.first()) {
|
||||||
let answer = cx
|
let answer = cx.prompt(
|
||||||
.prompt(
|
workspace.window_id(),
|
||||||
workspace.window_id(),
|
PromptLevel::Info,
|
||||||
PromptLevel::Info,
|
"Are you sure you want to restart?",
|
||||||
"Are you sure you want to restart?",
|
&["Restart", "Cancel"],
|
||||||
&["Restart", "Cancel"],
|
);
|
||||||
)
|
|
||||||
.next()
|
if let Some(mut answer) = answer {
|
||||||
.await;
|
let answer = answer.next().await;
|
||||||
if answer != Some(0) {
|
if answer != Some(0) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,17 +425,18 @@ fn quit(_: &Quit, cx: &mut gpui::AppContext) {
|
||||||
let should_confirm = cx.global::<Settings>().confirm_quit;
|
let should_confirm = cx.global::<Settings>().confirm_quit;
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
if let (true, Some(workspace)) = (should_confirm, workspaces.first()) {
|
if let (true, Some(workspace)) = (should_confirm, workspaces.first()) {
|
||||||
let answer = cx
|
let answer = cx.prompt(
|
||||||
.prompt(
|
workspace.window_id(),
|
||||||
workspace.window_id(),
|
PromptLevel::Info,
|
||||||
PromptLevel::Info,
|
"Are you sure you want to quit?",
|
||||||
"Are you sure you want to quit?",
|
&["Quit", "Cancel"],
|
||||||
&["Quit", "Cancel"],
|
);
|
||||||
)
|
|
||||||
.next()
|
if let Some(mut answer) = answer {
|
||||||
.await;
|
let answer = answer.next().await;
|
||||||
if answer != Some(0) {
|
if answer != Some(0) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,7 +714,7 @@ mod tests {
|
||||||
.await;
|
.await;
|
||||||
assert_eq!(cx.window_ids().len(), 1);
|
assert_eq!(cx.window_ids().len(), 1);
|
||||||
let workspace_1 = cx
|
let workspace_1 = cx
|
||||||
.root_view(cx.window_ids()[0])
|
.read_window(cx.window_ids()[0], |cx| cx.root_view().clone())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.downcast::<Workspace>()
|
.downcast::<Workspace>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -746,9 +748,8 @@ mod tests {
|
||||||
.await;
|
.await;
|
||||||
assert_eq!(cx.window_ids().len(), 2);
|
assert_eq!(cx.window_ids().len(), 2);
|
||||||
let workspace_1 = cx
|
let workspace_1 = cx
|
||||||
.root_view(window_id)
|
.read_window(window_id, |cx| cx.root_view().clone())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.clone()
|
|
||||||
.downcast::<Workspace>()
|
.downcast::<Workspace>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
workspace_1.read_with(cx, |workspace, cx| {
|
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.
|
// When opening the workspace, the window is not in a edited state.
|
||||||
let workspace = cx
|
let workspace = cx
|
||||||
.root_view(cx.window_ids()[0])
|
.read_window(cx.window_ids()[0], |cx| cx.root_view().clone())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.clone()
|
|
||||||
.downcast::<Workspace>()
|
.downcast::<Workspace>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let editor = workspace.read_with(cx, |workspace, cx| {
|
let editor = workspace.read_with(cx, |workspace, cx| {
|
||||||
|
@ -851,11 +851,11 @@ mod tests {
|
||||||
|
|
||||||
let window_id = *cx.window_ids().first().unwrap();
|
let window_id = *cx.window_ids().first().unwrap();
|
||||||
let workspace = cx
|
let workspace = cx
|
||||||
.root_view(window_id)
|
.read_window(window_id, |cx| cx.root_view().clone())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.clone()
|
|
||||||
.downcast::<Workspace>()
|
.downcast::<Workspace>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let editor = workspace.update(cx, |workspace, cx| {
|
let editor = workspace.update(cx, |workspace, cx| {
|
||||||
workspace
|
workspace
|
||||||
.active_item(cx)
|
.active_item(cx)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue