mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Get compiling
This commit is contained in:
parent
3e0d0e5c01
commit
486f5bc6ca
@ -3446,7 +3446,7 @@ async fn test_newline_above_or_below_does_not_move_guest_cursor(
|
|||||||
let editor_a = window_a.add_view(cx_a, |cx| Editor::for_buffer(buffer_a, Some(project_a), cx));
|
let editor_a = window_a.add_view(cx_a, |cx| Editor::for_buffer(buffer_a, Some(project_a), cx));
|
||||||
let mut editor_cx_a = EditorTestContext {
|
let mut editor_cx_a = EditorTestContext {
|
||||||
cx: cx_a,
|
cx: cx_a,
|
||||||
window_id: window_a.id(),
|
window: window_a.into(),
|
||||||
editor: editor_a,
|
editor: editor_a,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3459,7 +3459,7 @@ async fn test_newline_above_or_below_does_not_move_guest_cursor(
|
|||||||
let editor_b = window_b.add_view(cx_b, |cx| Editor::for_buffer(buffer_b, Some(project_b), cx));
|
let editor_b = window_b.add_view(cx_b, |cx| Editor::for_buffer(buffer_b, Some(project_b), cx));
|
||||||
let mut editor_cx_b = EditorTestContext {
|
let mut editor_cx_b = EditorTestContext {
|
||||||
cx: cx_b,
|
cx: cx_b,
|
||||||
window_id: window_b.id(),
|
window: window_b.into(),
|
||||||
editor: editor_b,
|
editor: editor_b,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use gpui::{
|
|||||||
elements::*,
|
elements::*,
|
||||||
geometry::{rect::RectF, vector::vec2f},
|
geometry::{rect::RectF, vector::vec2f},
|
||||||
platform::{CursorStyle, MouseButton, WindowBounds, WindowKind, WindowOptions},
|
platform::{CursorStyle, MouseButton, WindowBounds, WindowKind, WindowOptions},
|
||||||
AppContext, Entity, View, ViewContext,
|
AppContext, BorrowWindowContext, Entity, View, ViewContext,
|
||||||
};
|
};
|
||||||
use std::sync::{Arc, Weak};
|
use std::sync::{Arc, Weak};
|
||||||
use workspace::AppState;
|
use workspace::AppState;
|
||||||
|
@ -20,11 +20,11 @@ pub fn init(cx: &mut AppContext) {
|
|||||||
{
|
{
|
||||||
status_indicator = Some(cx.add_status_bar_item(|_| SharingStatusIndicator));
|
status_indicator = Some(cx.add_status_bar_item(|_| SharingStatusIndicator));
|
||||||
}
|
}
|
||||||
} else if let Some((window_id, _)) = status_indicator.take() {
|
} else if let Some(window) = status_indicator.take() {
|
||||||
cx.update_window(window_id, |cx| cx.remove_window());
|
window.update(cx, |cx| cx.remove_window());
|
||||||
}
|
}
|
||||||
} else if let Some((window_id, _)) = status_indicator.take() {
|
} else if let Some(window) = status_indicator.take() {
|
||||||
cx.update_window(window_id, |cx| cx.remove_window());
|
window.update(cx, |cx| cx.remove_window());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
@ -1290,7 +1290,7 @@ async fn test_move_start_of_paragraph_end_of_paragraph(cx: &mut gpui::TestAppCon
|
|||||||
let mut cx = EditorTestContext::new(cx).await;
|
let mut cx = EditorTestContext::new(cx).await;
|
||||||
|
|
||||||
let line_height = cx.editor(|editor, cx| editor.style(cx).text.line_height(cx.font_cache()));
|
let line_height = cx.editor(|editor, cx| editor.style(cx).text.line_height(cx.font_cache()));
|
||||||
cx.simulate_window_resize(cx.window_id, vec2f(100., 4. * line_height));
|
cx.simulate_window_resize(cx.window.id(), vec2f(100., 4. * line_height));
|
||||||
|
|
||||||
cx.set_state(
|
cx.set_state(
|
||||||
&r#"ˇone
|
&r#"ˇone
|
||||||
@ -1401,7 +1401,7 @@ async fn test_scroll_page_up_page_down(cx: &mut gpui::TestAppContext) {
|
|||||||
init_test(cx, |_| {});
|
init_test(cx, |_| {});
|
||||||
let mut cx = EditorTestContext::new(cx).await;
|
let mut cx = EditorTestContext::new(cx).await;
|
||||||
let line_height = cx.editor(|editor, cx| editor.style(cx).text.line_height(cx.font_cache()));
|
let line_height = cx.editor(|editor, cx| editor.style(cx).text.line_height(cx.font_cache()));
|
||||||
cx.simulate_window_resize(cx.window_id, vec2f(1000., 4. * line_height + 0.5));
|
cx.simulate_window_resize(cx.window.id(), vec2f(1000., 4. * line_height + 0.5));
|
||||||
|
|
||||||
cx.set_state(
|
cx.set_state(
|
||||||
&r#"ˇone
|
&r#"ˇone
|
||||||
@ -1439,7 +1439,7 @@ async fn test_move_page_up_page_down(cx: &mut gpui::TestAppContext) {
|
|||||||
let mut cx = EditorTestContext::new(cx).await;
|
let mut cx = EditorTestContext::new(cx).await;
|
||||||
|
|
||||||
let line_height = cx.editor(|editor, cx| editor.style(cx).text.line_height(cx.font_cache()));
|
let line_height = cx.editor(|editor, cx| editor.style(cx).text.line_height(cx.font_cache()));
|
||||||
cx.simulate_window_resize(cx.window_id, vec2f(100., 4. * line_height));
|
cx.simulate_window_resize(cx.window.id(), vec2f(100., 4. * line_height));
|
||||||
|
|
||||||
cx.set_state(
|
cx.set_state(
|
||||||
&r#"
|
&r#"
|
||||||
|
@ -99,7 +99,7 @@ impl<'a> EditorLspTestContext<'a> {
|
|||||||
Self {
|
Self {
|
||||||
cx: EditorTestContext {
|
cx: EditorTestContext {
|
||||||
cx,
|
cx,
|
||||||
window_id: window.id(),
|
window: window.into(),
|
||||||
editor,
|
editor,
|
||||||
},
|
},
|
||||||
lsp,
|
lsp,
|
||||||
|
@ -3,7 +3,8 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
keymap_matcher::Keystroke, AppContext, ContextHandle, ModelContext, ViewContext, ViewHandle,
|
keymap_matcher::Keystroke, AnyWindowHandle, AppContext, ContextHandle, ModelContext,
|
||||||
|
ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
use language::{Buffer, BufferSnapshot};
|
use language::{Buffer, BufferSnapshot};
|
||||||
@ -21,7 +22,7 @@ use super::build_editor;
|
|||||||
|
|
||||||
pub struct EditorTestContext<'a> {
|
pub struct EditorTestContext<'a> {
|
||||||
pub cx: &'a mut gpui::TestAppContext,
|
pub cx: &'a mut gpui::TestAppContext,
|
||||||
pub window_id: usize,
|
pub window: AnyWindowHandle,
|
||||||
pub editor: ViewHandle<Editor>,
|
pub editor: ViewHandle<Editor>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ impl<'a> EditorTestContext<'a> {
|
|||||||
let editor = window.root(cx);
|
let editor = window.root(cx);
|
||||||
Self {
|
Self {
|
||||||
cx,
|
cx,
|
||||||
window_id: window.id(),
|
window: window.into(),
|
||||||
editor,
|
editor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,7 +112,8 @@ impl<'a> EditorTestContext<'a> {
|
|||||||
let keystroke_under_test_handle =
|
let keystroke_under_test_handle =
|
||||||
self.add_assertion_context(format!("Simulated Keystroke: {:?}", keystroke_text));
|
self.add_assertion_context(format!("Simulated Keystroke: {:?}", keystroke_text));
|
||||||
let keystroke = Keystroke::parse(keystroke_text).unwrap();
|
let keystroke = Keystroke::parse(keystroke_text).unwrap();
|
||||||
self.cx.dispatch_keystroke(self.window_id, keystroke, false);
|
|
||||||
|
self.cx.dispatch_keystroke(self.window, keystroke, false);
|
||||||
keystroke_under_test_handle
|
keystroke_under_test_handle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,14 +135,16 @@ impl Entity for GoToLine {
|
|||||||
|
|
||||||
fn release(&mut self, cx: &mut AppContext) {
|
fn release(&mut self, cx: &mut AppContext) {
|
||||||
let scroll_position = self.prev_scroll_position.take();
|
let scroll_position = self.prev_scroll_position.take();
|
||||||
cx.update_window(self.active_editor.window_id(), |cx| {
|
if let Some(window) = self.active_editor.window(cx) {
|
||||||
self.active_editor.update(cx, |editor, cx| {
|
window.update(cx, |cx| {
|
||||||
editor.highlight_rows(None);
|
self.active_editor.update(cx, |editor, cx| {
|
||||||
if let Some(scroll_position) = scroll_position {
|
editor.highlight_rows(None);
|
||||||
editor.set_scroll_position(scroll_position, cx);
|
if let Some(scroll_position) = scroll_position {
|
||||||
}
|
editor.set_scroll_position(scroll_position, cx);
|
||||||
})
|
}
|
||||||
});
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
|
|
||||||
use derive_more::Deref;
|
use derive_more::Deref;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use postage::oneshot;
|
use postage::oneshot;
|
||||||
@ -4127,6 +4128,12 @@ impl<T: View> ViewHandle<T> {
|
|||||||
self.window_id
|
self.window_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn window<C: BorrowWindowContext>(&self, cx: &C) -> C::Result<AnyWindowHandle> {
|
||||||
|
cx.read_window(self.window_id, |cx| {
|
||||||
|
AnyWindowHandle::new(self.window_id, cx.window.root_view.type_id())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn id(&self) -> usize {
|
pub fn id(&self) -> usize {
|
||||||
self.view_id
|
self.view_id
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ impl BorrowWindowContext for WindowContext<'_> {
|
|||||||
where
|
where
|
||||||
F: FnOnce(&mut WindowContext) -> Option<T>,
|
F: FnOnce(&mut WindowContext) -> Option<T>,
|
||||||
{
|
{
|
||||||
BorrowWindowContext::update_window_optional(self, window_id, f)
|
BorrowWindowContext::update_window(self, window_id, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::Vim;
|
use crate::Vim;
|
||||||
use editor::{EditorBlurred, EditorFocused, EditorReleased};
|
use editor::{EditorBlurred, EditorFocused, EditorReleased};
|
||||||
use gpui::AppContext;
|
use gpui::{AppContext, BorrowWindowContext};
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.subscribe_global(focused).detach();
|
cx.subscribe_global(focused).detach();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use gpui::{
|
use gpui::{
|
||||||
elements::{Empty, Label},
|
elements::{Empty, Label},
|
||||||
AnyElement, Element, Entity, Subscription, View, ViewContext,
|
AnyElement, Element, Entity, Subscription, View, ViewContext, BorrowWindowContext
|
||||||
};
|
};
|
||||||
use settings::SettingsStore;
|
use settings::SettingsStore;
|
||||||
use workspace::{item::ItemHandle, StatusItemView};
|
use workspace::{item::ItemHandle, StatusItemView};
|
||||||
|
@ -85,7 +85,7 @@ impl<'a> VimTestContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_state(&mut self, text: &str, mode: Mode) -> ContextHandle {
|
pub fn set_state(&mut self, text: &str, mode: Mode) -> ContextHandle {
|
||||||
let window_id = self.window_id;
|
let window_id = self.window.id();
|
||||||
self.update_window(window_id, |cx| {
|
self.update_window(window_id, |cx| {
|
||||||
Vim::update(cx, |vim, cx| {
|
Vim::update(cx, |vim, cx| {
|
||||||
vim.switch_mode(mode, false, cx);
|
vim.switch_mode(mode, false, cx);
|
||||||
|
@ -3827,9 +3827,9 @@ pub fn activate_workspace_for_project(
|
|||||||
cx: &mut AsyncAppContext,
|
cx: &mut AsyncAppContext,
|
||||||
predicate: impl Fn(&mut Project, &mut ModelContext<Project>) -> bool,
|
predicate: impl Fn(&mut Project, &mut ModelContext<Project>) -> bool,
|
||||||
) -> Option<WeakViewHandle<Workspace>> {
|
) -> Option<WeakViewHandle<Workspace>> {
|
||||||
for window_id in cx.window_ids() {
|
for window in cx.windows() {
|
||||||
let handle = cx
|
let handle = window
|
||||||
.update_window(window_id, |cx| {
|
.update(cx, |cx| {
|
||||||
if let Some(workspace_handle) = cx.root_view().clone().downcast::<Workspace>() {
|
if let Some(workspace_handle) = cx.root_view().clone().downcast::<Workspace>() {
|
||||||
let project = workspace_handle.read(cx).project.clone();
|
let project = workspace_handle.read(cx).project.clone();
|
||||||
if project.update(cx, &predicate) {
|
if project.update(cx, &predicate) {
|
||||||
@ -3945,18 +3945,23 @@ pub fn join_remote_project(
|
|||||||
) -> Task<Result<()>> {
|
) -> Task<Result<()>> {
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
let existing_workspace = cx
|
let existing_workspace = cx
|
||||||
.window_ids()
|
.windows()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|window_id| cx.root_view(window_id)?.clone().downcast::<Workspace>())
|
.find_map(|window| {
|
||||||
.find(|workspace| {
|
window.downcast::<Workspace>().and_then(|window| {
|
||||||
cx.read_window(workspace.window_id(), |cx| {
|
window.read_root_with(&cx, |workspace, cx| {
|
||||||
workspace.read(cx).project().read(cx).remote_id() == Some(project_id)
|
if workspace.project().read(cx).remote_id() == Some(project_id) {
|
||||||
|
Some(cx.handle().downgrade())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.unwrap_or(false)
|
})
|
||||||
});
|
.flatten();
|
||||||
|
|
||||||
let workspace = if let Some(existing_workspace) = existing_workspace {
|
let workspace = if let Some(existing_workspace) = existing_workspace {
|
||||||
existing_workspace.downgrade()
|
existing_workspace
|
||||||
} else {
|
} else {
|
||||||
let active_call = cx.read(ActiveCall::global);
|
let active_call = cx.read(ActiveCall::global);
|
||||||
let room = active_call
|
let room = active_call
|
||||||
@ -4034,19 +4039,19 @@ pub fn join_remote_project(
|
|||||||
pub fn restart(_: &Restart, cx: &mut AppContext) {
|
pub fn restart(_: &Restart, cx: &mut AppContext) {
|
||||||
let should_confirm = settings::get::<WorkspaceSettings>(cx).confirm_quit;
|
let should_confirm = settings::get::<WorkspaceSettings>(cx).confirm_quit;
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
let mut workspaces = cx
|
let mut workspace_windows = cx
|
||||||
.windows()
|
.windows()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|window| Some(window.downcast::<Workspace>()?.root(&cx)?.downgrade()))
|
.filter_map(|window| window.downcast::<Workspace>())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
// If multiple windows have unsaved changes, and need a save prompt,
|
// If multiple windows have unsaved changes, and need a save prompt,
|
||||||
// prompt in the active window before switching to a different window.
|
// prompt in the active window before switching to a different window.
|
||||||
workspaces.sort_by_key(|workspace| !cx.window_is_active(workspace.window_id()));
|
workspace_windows.sort_by_key(|window| window.is_active(&cx) == Some(false));
|
||||||
|
|
||||||
if let (true, Some(workspace)) = (should_confirm, workspaces.first()) {
|
if let (true, Some(window)) = (should_confirm, workspace_windows.first()) {
|
||||||
let answer = cx.prompt(
|
let answer = cx.prompt(
|
||||||
workspace.window_id(),
|
window.id(),
|
||||||
PromptLevel::Info,
|
PromptLevel::Info,
|
||||||
"Are you sure you want to restart?",
|
"Are you sure you want to restart?",
|
||||||
&["Restart", "Cancel"],
|
&["Restart", "Cancel"],
|
||||||
@ -4061,14 +4066,13 @@ pub fn restart(_: &Restart, cx: &mut AppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the user cancels any save prompt, then keep the app open.
|
// If the user cancels any save prompt, then keep the app open.
|
||||||
for workspace in workspaces {
|
for window in workspace_windows {
|
||||||
if !workspace
|
if let Some(close) = window.update_root(&mut cx, |workspace, cx| {
|
||||||
.update(&mut cx, |workspace, cx| {
|
workspace.prepare_to_close(true, cx)
|
||||||
workspace.prepare_to_close(true, cx)
|
}) {
|
||||||
})?
|
if !close.await? {
|
||||||
.await?
|
return Ok(());
|
||||||
{
|
}
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cx.platform().restart();
|
cx.platform().restart();
|
||||||
|
@ -406,26 +406,19 @@ pub fn build_window_options(
|
|||||||
fn quit(_: &Quit, cx: &mut gpui::AppContext) {
|
fn quit(_: &Quit, cx: &mut gpui::AppContext) {
|
||||||
let should_confirm = settings::get::<WorkspaceSettings>(cx).confirm_quit;
|
let should_confirm = settings::get::<WorkspaceSettings>(cx).confirm_quit;
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
let mut workspaces = cx
|
let mut workspace_windows = cx
|
||||||
.window_ids()
|
.windows()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|window_id| {
|
.filter_map(|window| window.downcast::<Workspace>())
|
||||||
Some(
|
|
||||||
cx.root_view(window_id)?
|
|
||||||
.clone()
|
|
||||||
.downcast::<Workspace>()?
|
|
||||||
.downgrade(),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
// If multiple windows have unsaved changes, and need a save prompt,
|
// If multiple windows have unsaved changes, and need a save prompt,
|
||||||
// prompt in the active window before switching to a different window.
|
// prompt in the active window before switching to a different window.
|
||||||
workspaces.sort_by_key(|workspace| !cx.window_is_active(workspace.window_id()));
|
workspace_windows.sort_by_key(|window| window.is_active(&cx) == Some(false));
|
||||||
|
|
||||||
if let (true, Some(workspace)) = (should_confirm, workspaces.first()) {
|
if let (true, Some(window)) = (should_confirm, workspace_windows.first()) {
|
||||||
let answer = cx.prompt(
|
let answer = cx.prompt(
|
||||||
workspace.window_id(),
|
window.id(),
|
||||||
PromptLevel::Info,
|
PromptLevel::Info,
|
||||||
"Are you sure you want to quit?",
|
"Are you sure you want to quit?",
|
||||||
&["Quit", "Cancel"],
|
&["Quit", "Cancel"],
|
||||||
@ -440,14 +433,13 @@ fn quit(_: &Quit, cx: &mut gpui::AppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the user cancels any save prompt, then keep the app open.
|
// If the user cancels any save prompt, then keep the app open.
|
||||||
for workspace in workspaces {
|
for window in workspace_windows {
|
||||||
if !workspace
|
if let Some(close) = window.update_root(&mut cx, |workspace, cx| {
|
||||||
.update(&mut cx, |workspace, cx| {
|
workspace.prepare_to_close(false, cx)
|
||||||
workspace.prepare_to_close(true, cx)
|
}) {
|
||||||
})?
|
if close.await? {
|
||||||
.await?
|
return Ok(());
|
||||||
{
|
}
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cx.platform().quit();
|
cx.platform().quit();
|
||||||
@ -782,17 +774,13 @@ mod tests {
|
|||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(cx.window_ids().len(), 1);
|
assert_eq!(cx.windows().len(), 1);
|
||||||
|
|
||||||
cx.update(|cx| open_paths(&[PathBuf::from("/root/a")], &app_state, None, cx))
|
cx.update(|cx| open_paths(&[PathBuf::from("/root/a")], &app_state, None, cx))
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(cx.window_ids().len(), 1);
|
assert_eq!(cx.windows().len(), 1);
|
||||||
let workspace_1 = cx
|
let workspace_1 = cx.windows()[0].downcast::<Workspace>().unwrap().root(cx);
|
||||||
.read_window(cx.window_ids()[0], |cx| cx.root_view().clone())
|
|
||||||
.unwrap()
|
|
||||||
.downcast::<Workspace>()
|
|
||||||
.unwrap();
|
|
||||||
workspace_1.update(cx, |workspace, cx| {
|
workspace_1.update(cx, |workspace, cx| {
|
||||||
assert_eq!(workspace.worktrees(cx).count(), 2);
|
assert_eq!(workspace.worktrees(cx).count(), 2);
|
||||||
assert!(workspace.left_dock().read(cx).is_open());
|
assert!(workspace.left_dock().read(cx).is_open());
|
||||||
@ -809,28 +797,22 @@ mod tests {
|
|||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(cx.window_ids().len(), 2);
|
assert_eq!(cx.windows().len(), 2);
|
||||||
|
|
||||||
// Replace existing windows
|
// Replace existing windows
|
||||||
let window_id = cx.window_ids()[0];
|
let window = cx.windows()[0].downcast::<Workspace>().unwrap();
|
||||||
let window = cx.read_window(window_id, |cx| cx.window()).flatten();
|
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
open_paths(
|
open_paths(
|
||||||
&[PathBuf::from("/root/c"), PathBuf::from("/root/d")],
|
&[PathBuf::from("/root/c"), PathBuf::from("/root/d")],
|
||||||
&app_state,
|
&app_state,
|
||||||
window,
|
Some(window),
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(cx.window_ids().len(), 2);
|
assert_eq!(cx.windows().len(), 2);
|
||||||
let workspace_1 = cx
|
let workspace_1 = cx.windows()[0].downcast::<Workspace>().unwrap().root(cx);
|
||||||
.read_window(cx.window_ids()[0], |cx| cx.root_view().clone())
|
|
||||||
.unwrap()
|
|
||||||
.clone()
|
|
||||||
.downcast::<Workspace>()
|
|
||||||
.unwrap();
|
|
||||||
workspace_1.update(cx, |workspace, cx| {
|
workspace_1.update(cx, |workspace, cx| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
workspace
|
workspace
|
||||||
@ -856,14 +838,10 @@ mod tests {
|
|||||||
cx.update(|cx| open_paths(&[PathBuf::from("/root/a")], &app_state, None, cx))
|
cx.update(|cx| open_paths(&[PathBuf::from("/root/a")], &app_state, None, cx))
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(cx.window_ids().len(), 1);
|
assert_eq!(cx.windows().len(), 1);
|
||||||
|
|
||||||
// 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.windows()[0].downcast::<Workspace>().unwrap().root(cx);
|
||||||
.read_window(cx.window_ids()[0], |cx| cx.root_view().clone())
|
|
||||||
.unwrap()
|
|
||||||
.downcast::<Workspace>()
|
|
||||||
.unwrap();
|
|
||||||
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
let editor = workspace.read_with(cx, |workspace, cx| {
|
let editor = workspace.read_with(cx, |workspace, cx| {
|
||||||
workspace
|
workspace
|
||||||
@ -917,12 +895,12 @@ mod tests {
|
|||||||
// buffer having unsaved changes.
|
// buffer having unsaved changes.
|
||||||
assert!(!cx.simulate_window_close(workspace.window_id()));
|
assert!(!cx.simulate_window_close(workspace.window_id()));
|
||||||
executor.run_until_parked();
|
executor.run_until_parked();
|
||||||
assert_eq!(cx.window_ids().len(), 1);
|
assert_eq!(cx.windows().len(), 1);
|
||||||
|
|
||||||
// The window is successfully closed after the user dismisses the prompt.
|
// The window is successfully closed after the user dismisses the prompt.
|
||||||
cx.simulate_prompt_answer(workspace.window_id(), 1);
|
cx.simulate_prompt_answer(workspace.window_id(), 1);
|
||||||
executor.run_until_parked();
|
executor.run_until_parked();
|
||||||
assert_eq!(cx.window_ids().len(), 0);
|
assert_eq!(cx.windows().len(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
@ -935,12 +913,13 @@ mod tests {
|
|||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let window_id = *cx.window_ids().first().unwrap();
|
let window = cx
|
||||||
let workspace = cx
|
.windows()
|
||||||
.read_window(window_id, |cx| cx.root_view().clone())
|
.first()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.downcast::<Workspace>()
|
.downcast::<Workspace>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let workspace = window.root(cx);
|
||||||
|
|
||||||
let editor = workspace.update(cx, |workspace, cx| {
|
let editor = workspace.update(cx, |workspace, cx| {
|
||||||
workspace
|
workspace
|
||||||
@ -1105,12 +1084,8 @@ mod tests {
|
|||||||
cx.update(|cx| open_paths(&[PathBuf::from("/dir1/")], &app_state, None, cx))
|
cx.update(|cx| open_paths(&[PathBuf::from("/dir1/")], &app_state, None, cx))
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(cx.window_ids().len(), 1);
|
assert_eq!(cx.windows().len(), 1);
|
||||||
let workspace = cx
|
let workspace = cx.windows()[0].downcast::<Workspace>().unwrap().root(cx);
|
||||||
.read_window(cx.window_ids()[0], |cx| cx.root_view().clone())
|
|
||||||
.unwrap()
|
|
||||||
.downcast::<Workspace>()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn assert_project_panel_selection(
|
fn assert_project_panel_selection(
|
||||||
|
Loading…
Reference in New Issue
Block a user