Merge remote-tracking branch 'origin/main' into into-element

This commit is contained in:
Nathan Sobo 2023-04-21 14:27:25 -06:00
commit 993dbf86cb
12 changed files with 82 additions and 65 deletions

1
Cargo.lock generated
View file

@ -1358,7 +1358,6 @@ dependencies = [
"smol", "smol",
"theme", "theme",
"util", "util",
"workspace",
] ]
[[package]] [[package]]

View file

@ -18,7 +18,9 @@
], ],
"ctrl-shift-down": "editor::AddSelectionBelow", "ctrl-shift-down": "editor::AddSelectionBelow",
"ctrl-shift-up": "editor::AddSelectionAbove", "ctrl-shift-up": "editor::AddSelectionAbove",
"cmd-shift-backspace": "editor::DeleteToBeginningOfLine" "cmd-shift-backspace": "editor::DeleteToBeginningOfLine",
"cmd-shift-enter": "editor::NewlineAbove",
"cmd-enter": "editor::NewlineBelow"
} }
}, },
{ {

View file

@ -14,6 +14,7 @@
"cmd-pagedown": "editor::MovePageDown", "cmd-pagedown": "editor::MovePageDown",
"cmd-pageup": "editor::MovePageUp", "cmd-pageup": "editor::MovePageUp",
"ctrl-alt-shift-b": "editor::SelectToPreviousWordStart", "ctrl-alt-shift-b": "editor::SelectToPreviousWordStart",
"cmd-alt-enter": "editor::NewlineAbove",
"shift-enter": "editor::NewlineBelow", "shift-enter": "editor::NewlineBelow",
"cmd--": "editor::Fold", "cmd--": "editor::Fold",
"cmd-=": "editor::UnfoldLines", "cmd-=": "editor::UnfoldLines",

View file

@ -24,7 +24,9 @@
"ctrl-.": "editor::GoToHunk", "ctrl-.": "editor::GoToHunk",
"ctrl-,": "editor::GoToPrevHunk", "ctrl-,": "editor::GoToPrevHunk",
"ctrl-backspace": "editor::DeleteToPreviousWordStart", "ctrl-backspace": "editor::DeleteToPreviousWordStart",
"ctrl-delete": "editor::DeleteToNextWordEnd" "ctrl-delete": "editor::DeleteToNextWordEnd",
"cmd-shift-enter": "editor::NewlineAbove",
"cmd-enter": "editor::NewlineBelow"
} }
}, },
{ {

View file

@ -12,6 +12,7 @@
"ctrl-shift-d": "editor::DuplicateLine", "ctrl-shift-d": "editor::DuplicateLine",
"cmd-b": "editor::GoToDefinition", "cmd-b": "editor::GoToDefinition",
"cmd-j": "editor::ScrollCursorCenter", "cmd-j": "editor::ScrollCursorCenter",
"cmd-alt-enter": "editor::NewlineAbove",
"cmd-enter": "editor::NewlineBelow", "cmd-enter": "editor::NewlineBelow",
"cmd-shift-l": "editor::SelectLine", "cmd-shift-l": "editor::SelectLine",
"cmd-shift-t": "outline::Toggle", "cmd-shift-t": "outline::Toggle",

View file

@ -47,4 +47,3 @@ lsp = { path = "../lsp", features = ["test-support"] }
rpc = { path = "../rpc", features = ["test-support"] } rpc = { path = "../rpc", features = ["test-support"] }
settings = { path = "../settings", features = ["test-support"] } settings = { path = "../settings", features = ["test-support"] }
util = { path = "../util", features = ["test-support"] } util = { path = "../util", features = ["test-support"] }
workspace = { path = "../workspace", features = ["test-support"] }

View file

@ -378,13 +378,6 @@ impl Copilot {
cx.clone(), cx.clone(),
)?; )?;
let server = server.initialize(Default::default()).await?;
let status = server
.request::<request::CheckStatus>(request::CheckStatusParams {
local_checks_only: false,
})
.await?;
server server
.on_notification::<LogMessage, _>(|params, _cx| { .on_notification::<LogMessage, _>(|params, _cx| {
match params.level { match params.level {
@ -405,6 +398,14 @@ impl Copilot {
) )
.detach(); .detach();
let server = server.initialize(Default::default()).await?;
let status = server
.request::<request::CheckStatus>(request::CheckStatusParams {
local_checks_only: false,
})
.await?;
server server
.request::<request::SetEditorInfo>(request::SetEditorInfoParams { .request::<request::SetEditorInfo>(request::SetEditorInfoParams {
editor_info: request::EditorInfo { editor_info: request::EditorInfo {

View file

@ -143,8 +143,8 @@ pub enum LogMessage {}
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct LogMessageParams { pub struct LogMessageParams {
pub message: String,
pub level: u8, pub level: u8,
pub message: String,
pub metadata_str: String, pub metadata_str: String,
pub extra: Vec<String>, pub extra: Vec<String>,
} }

View file

@ -80,8 +80,8 @@ pub enum BlockStyle {
Sticky, Sticky,
} }
pub struct BlockContext<'a, 'b, 'c, 'd> { pub struct BlockContext<'a, 'b, 'c> {
pub view_context: &'d mut ViewContext<'a, 'b, 'c, Editor>, pub view_context: &'c mut ViewContext<'a, 'b, Editor>,
pub anchor_x: f32, pub anchor_x: f32,
pub scroll_x: f32, pub scroll_x: f32,
pub gutter_width: f32, pub gutter_width: f32,
@ -932,15 +932,15 @@ impl BlockDisposition {
} }
} }
impl<'a, 'b, 'c, 'd> Deref for BlockContext<'a, 'b, 'c, 'd> { impl<'a, 'b, 'c> Deref for BlockContext<'a, 'b, 'c> {
type Target = ViewContext<'a, 'b, 'c, Editor>; type Target = ViewContext<'a, 'b, Editor>;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
self.view_context self.view_context
} }
} }
impl DerefMut for BlockContext<'_, '_, '_, '_> { impl DerefMut for BlockContext<'_, '_, '_> {
fn deref_mut(&mut self) -> &mut Self::Target { fn deref_mut(&mut self) -> &mut Self::Target {
self.view_context self.view_context
} }

View file

@ -69,7 +69,7 @@ pub trait Entity: 'static {
pub trait View: Entity + Sized { pub trait View: Entity + Sized {
fn ui_name() -> &'static str; fn ui_name() -> &'static str;
fn render(&mut self, cx: &mut ViewContext<'_, '_, '_, Self>) -> AnyElement<Self>; fn render(&mut self, cx: &mut ViewContext<'_, '_, Self>) -> AnyElement<Self>;
fn focus_in(&mut self, _: AnyViewHandle, _: &mut ViewContext<Self>) {} fn focus_in(&mut self, _: AnyViewHandle, _: &mut ViewContext<Self>) {}
fn focus_out(&mut self, _: AnyViewHandle, _: &mut ViewContext<Self>) {} fn focus_out(&mut self, _: AnyViewHandle, _: &mut ViewContext<Self>) {}
fn key_down(&mut self, _: &KeyDownEvent, _: &mut ViewContext<Self>) -> bool { fn key_down(&mut self, _: &KeyDownEvent, _: &mut ViewContext<Self>) -> bool {
@ -2518,12 +2518,7 @@ pub trait AnyView {
) -> Option<Pin<Box<dyn 'static + Future<Output = ()>>>>; ) -> Option<Pin<Box<dyn 'static + Future<Output = ()>>>>;
fn ui_name(&self) -> &'static str; fn ui_name(&self) -> &'static str;
fn render(&mut self, cx: &mut WindowContext, view_id: usize) -> Box<dyn AnyRootElement>; fn render(&mut self, cx: &mut WindowContext, view_id: usize) -> Box<dyn AnyRootElement>;
fn focus_in<'a, 'b>( fn focus_in<'a, 'b>(&mut self, focused_id: usize, cx: &mut WindowContext<'a>, view_id: usize);
&mut self,
focused_id: usize,
cx: &mut WindowContext<'a, 'b>,
view_id: usize,
);
fn focus_out(&mut self, focused_id: usize, cx: &mut WindowContext, view_id: usize); fn focus_out(&mut self, focused_id: usize, cx: &mut WindowContext, view_id: usize);
fn key_down(&mut self, event: &KeyDownEvent, cx: &mut WindowContext, view_id: usize) -> bool; fn key_down(&mut self, event: &KeyDownEvent, cx: &mut WindowContext, view_id: usize) -> bool;
fn key_up(&mut self, event: &KeyUpEvent, cx: &mut WindowContext, view_id: usize) -> bool; fn key_up(&mut self, event: &KeyUpEvent, cx: &mut WindowContext, view_id: usize) -> bool;
@ -2919,28 +2914,28 @@ impl<M> DerefMut for ModelContext<'_, M> {
} }
} }
pub struct ViewContext<'a, 'b, 'c, T: ?Sized> { pub struct ViewContext<'a, 'b, T: ?Sized> {
window_context: Reference<'c, WindowContext<'a, 'b>>, window_context: Reference<'b, WindowContext<'a>>,
view_id: usize, view_id: usize,
view_type: PhantomData<T>, view_type: PhantomData<T>,
} }
impl<'a, 'b, 'c, T: View> Deref for ViewContext<'a, 'b, 'c, T> { impl<'a, 'b, T: View> Deref for ViewContext<'a, 'b, T> {
type Target = WindowContext<'a, 'b>; type Target = WindowContext<'a>;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
&self.window_context &self.window_context
} }
} }
impl<T: View> DerefMut for ViewContext<'_, '_, '_, T> { impl<T: View> DerefMut for ViewContext<'_, '_, T> {
fn deref_mut(&mut self) -> &mut Self::Target { fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.window_context &mut self.window_context
} }
} }
impl<'a, 'b, 'c, V: View> ViewContext<'a, 'b, 'c, V> { impl<'a, 'b, V: View> ViewContext<'a, 'b, V> {
pub(crate) fn mutable(window_context: &'c mut WindowContext<'a, 'b>, view_id: usize) -> Self { pub(crate) fn mutable(window_context: &'b mut WindowContext<'a>, view_id: usize) -> Self {
Self { Self {
window_context: Reference::Mutable(window_context), window_context: Reference::Mutable(window_context),
view_id, view_id,
@ -2948,7 +2943,7 @@ impl<'a, 'b, 'c, V: View> ViewContext<'a, 'b, 'c, V> {
} }
} }
pub(crate) fn immutable(window_context: &'c WindowContext<'a, 'b>, view_id: usize) -> Self { pub(crate) fn immutable(window_context: &'b WindowContext<'a>, view_id: usize) -> Self {
Self { Self {
window_context: Reference::Immutable(window_context), window_context: Reference::Immutable(window_context),
view_id, view_id,
@ -2956,7 +2951,7 @@ impl<'a, 'b, 'c, V: View> ViewContext<'a, 'b, 'c, V> {
} }
} }
pub fn window_context(&mut self) -> &mut WindowContext<'a, 'b> { pub fn window_context(&mut self) -> &mut WindowContext<'a> {
&mut self.window_context &mut self.window_context
} }
@ -3450,7 +3445,7 @@ impl<'a, 'b, 'c, V: View> ViewContext<'a, 'b, 'c, V> {
} }
} }
impl<V> UpgradeModelHandle for ViewContext<'_, '_, '_, V> { impl<V> UpgradeModelHandle for ViewContext<'_, '_, V> {
fn upgrade_model_handle<T: Entity>( fn upgrade_model_handle<T: Entity>(
&self, &self,
handle: &WeakModelHandle<T>, handle: &WeakModelHandle<T>,
@ -3467,7 +3462,7 @@ impl<V> UpgradeModelHandle for ViewContext<'_, '_, '_, V> {
} }
} }
impl<V> UpgradeViewHandle for ViewContext<'_, '_, '_, V> { impl<V> UpgradeViewHandle for ViewContext<'_, '_, V> {
fn upgrade_view_handle<T: View>(&self, handle: &WeakViewHandle<T>) -> Option<ViewHandle<T>> { fn upgrade_view_handle<T: View>(&self, handle: &WeakViewHandle<T>) -> Option<ViewHandle<T>> {
self.window_context.upgrade_view_handle(handle) self.window_context.upgrade_view_handle(handle)
} }
@ -3477,13 +3472,13 @@ impl<V> UpgradeViewHandle for ViewContext<'_, '_, '_, V> {
} }
} }
impl<V: View> ReadModel for ViewContext<'_, '_, '_, V> { impl<V: View> ReadModel for ViewContext<'_, '_, V> {
fn read_model<T: Entity>(&self, handle: &ModelHandle<T>) -> &T { fn read_model<T: Entity>(&self, handle: &ModelHandle<T>) -> &T {
self.window_context.read_model(handle) self.window_context.read_model(handle)
} }
} }
impl<V: View> UpdateModel for ViewContext<'_, '_, '_, V> { impl<V: View> UpdateModel for ViewContext<'_, '_, V> {
fn update_model<T: Entity, O>( fn update_model<T: Entity, O>(
&mut self, &mut self,
handle: &ModelHandle<T>, handle: &ModelHandle<T>,
@ -3493,13 +3488,13 @@ impl<V: View> UpdateModel for ViewContext<'_, '_, '_, V> {
} }
} }
impl<V: View> ReadView for ViewContext<'_, '_, '_, V> { impl<V: View> ReadView for ViewContext<'_, '_, V> {
fn read_view<T: View>(&self, handle: &ViewHandle<T>) -> &T { fn read_view<T: View>(&self, handle: &ViewHandle<T>) -> &T {
self.window_context.read_view(handle) self.window_context.read_view(handle)
} }
} }
impl<V: View> UpdateView for ViewContext<'_, '_, '_, V> { impl<V: View> UpdateView for ViewContext<'_, '_, V> {
type Output<S> = S; type Output<S> = S;
fn update_view<T, S>( fn update_view<T, S>(
@ -3514,13 +3509,13 @@ impl<V: View> UpdateView for ViewContext<'_, '_, '_, V> {
} }
} }
pub struct EventContext<'a, 'b, 'c, 'd, V: View> { pub struct EventContext<'a, 'b, 'c, V: View> {
view_context: &'d mut ViewContext<'a, 'b, 'c, V>, view_context: &'c mut ViewContext<'a, 'b, V>,
pub(crate) handled: bool, pub(crate) handled: bool,
} }
impl<'a, 'b, 'c, 'd, V: View> EventContext<'a, 'b, 'c, 'd, V> { impl<'a, 'b, 'c, V: View> EventContext<'a, 'b, 'c, V> {
pub(crate) fn new(view_context: &'d mut ViewContext<'a, 'b, 'c, V>) -> Self { pub(crate) fn new(view_context: &'c mut ViewContext<'a, 'b, V>) -> Self {
EventContext { EventContext {
view_context, view_context,
handled: true, handled: true,
@ -3532,21 +3527,21 @@ impl<'a, 'b, 'c, 'd, V: View> EventContext<'a, 'b, 'c, 'd, V> {
} }
} }
impl<'a, 'b, 'c, 'd, V: View> Deref for EventContext<'a, 'b, 'c, 'd, V> { impl<'a, 'b, 'c, V: View> Deref for EventContext<'a, 'b, 'c, V> {
type Target = ViewContext<'a, 'b, 'c, V>; type Target = ViewContext<'a, 'b, V>;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
&self.view_context &self.view_context
} }
} }
impl<V: View> DerefMut for EventContext<'_, '_, '_, '_, V> { impl<V: View> DerefMut for EventContext<'_, '_, '_, V> {
fn deref_mut(&mut self) -> &mut Self::Target { fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.view_context &mut self.view_context
} }
} }
impl<V: View> UpdateModel for EventContext<'_, '_, '_, '_, V> { impl<V: View> UpdateModel for EventContext<'_, '_, '_, V> {
fn update_model<T: Entity, O>( fn update_model<T: Entity, O>(
&mut self, &mut self,
handle: &ModelHandle<T>, handle: &ModelHandle<T>,
@ -3556,13 +3551,13 @@ impl<V: View> UpdateModel for EventContext<'_, '_, '_, '_, V> {
} }
} }
impl<V: View> ReadView for EventContext<'_, '_, '_, '_, V> { impl<V: View> ReadView for EventContext<'_, '_, '_, V> {
fn read_view<W: View>(&self, handle: &crate::ViewHandle<W>) -> &W { fn read_view<W: View>(&self, handle: &crate::ViewHandle<W>) -> &W {
self.view_context.read_view(handle) self.view_context.read_view(handle)
} }
} }
impl<V: View> UpdateView for EventContext<'_, '_, '_, '_, V> { impl<V: View> UpdateView for EventContext<'_, '_, '_, V> {
type Output<S> = S; type Output<S> = S;
fn update_view<T, S>( fn update_view<T, S>(
@ -3577,7 +3572,7 @@ impl<V: View> UpdateView for EventContext<'_, '_, '_, '_, V> {
} }
} }
impl<V: View> UpgradeModelHandle for EventContext<'_, '_, '_, '_, V> { impl<V: View> UpgradeModelHandle for EventContext<'_, '_, '_, V> {
fn upgrade_model_handle<T: Entity>( fn upgrade_model_handle<T: Entity>(
&self, &self,
handle: &WeakModelHandle<T>, handle: &WeakModelHandle<T>,
@ -3594,7 +3589,7 @@ impl<V: View> UpgradeModelHandle for EventContext<'_, '_, '_, '_, V> {
} }
} }
impl<V: View> UpgradeViewHandle for EventContext<'_, '_, '_, '_, V> { impl<V: View> UpgradeViewHandle for EventContext<'_, '_, '_, V> {
fn upgrade_view_handle<T: View>(&self, handle: &WeakViewHandle<T>) -> Option<ViewHandle<T>> { fn upgrade_view_handle<T: View>(&self, handle: &WeakViewHandle<T>) -> Option<ViewHandle<T>> {
self.view_context.upgrade_view_handle(handle) self.view_context.upgrade_view_handle(handle)
} }
@ -4106,7 +4101,7 @@ impl AnyViewHandle {
self.view_type self.view_type
} }
pub fn debug_json<'a, 'b>(&self, cx: &'b WindowContext<'a, 'b>) -> serde_json::Value { pub fn debug_json<'a, 'b>(&self, cx: &'b WindowContext<'a>) -> serde_json::Value {
cx.views cx.views
.get(&(self.window_id, self.view_id)) .get(&(self.window_id, self.view_id))
.map_or_else(|| serde_json::Value::Null, |view| view.debug_json(cx)) .map_or_else(|| serde_json::Value::Null, |view| view.debug_json(cx))

View file

@ -111,15 +111,15 @@ impl Window {
} }
} }
pub struct WindowContext<'a: 'b, 'b> { pub struct WindowContext<'a> {
pub(crate) app_context: Reference<'a, AppContext>, pub(crate) app_context: Reference<'a, AppContext>,
pub(crate) window: Reference<'b, Window>, pub(crate) window: Reference<'a, Window>,
pub(crate) window_id: usize, pub(crate) window_id: usize,
pub(crate) refreshing: bool, pub(crate) refreshing: bool,
pub(crate) removed: bool, pub(crate) removed: bool,
} }
impl Deref for WindowContext<'_, '_> { impl Deref for WindowContext<'_> {
type Target = AppContext; type Target = AppContext;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
@ -127,19 +127,19 @@ impl Deref for WindowContext<'_, '_> {
} }
} }
impl DerefMut for WindowContext<'_, '_> { impl DerefMut for WindowContext<'_> {
fn deref_mut(&mut self) -> &mut Self::Target { fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.app_context &mut self.app_context
} }
} }
impl ReadModel for WindowContext<'_, '_> { impl ReadModel for WindowContext<'_> {
fn read_model<T: Entity>(&self, handle: &ModelHandle<T>) -> &T { fn read_model<T: Entity>(&self, handle: &ModelHandle<T>) -> &T {
self.app_context.read_model(handle) self.app_context.read_model(handle)
} }
} }
impl UpdateModel for WindowContext<'_, '_> { impl UpdateModel for WindowContext<'_> {
fn update_model<T: Entity, R>( fn update_model<T: Entity, R>(
&mut self, &mut self,
handle: &ModelHandle<T>, handle: &ModelHandle<T>,
@ -149,13 +149,13 @@ impl UpdateModel for WindowContext<'_, '_> {
} }
} }
impl ReadView for WindowContext<'_, '_> { impl ReadView for WindowContext<'_> {
fn read_view<W: View>(&self, handle: &crate::ViewHandle<W>) -> &W { fn read_view<W: View>(&self, handle: &crate::ViewHandle<W>) -> &W {
self.app_context.read_view(handle) self.app_context.read_view(handle)
} }
} }
impl UpdateView for WindowContext<'_, '_> { impl UpdateView for WindowContext<'_> {
type Output<S> = S; type Output<S> = S;
fn update_view<T, S>( fn update_view<T, S>(
@ -179,7 +179,7 @@ impl UpdateView for WindowContext<'_, '_> {
} }
} }
impl UpgradeModelHandle for WindowContext<'_, '_> { impl UpgradeModelHandle for WindowContext<'_> {
fn upgrade_model_handle<T: Entity>( fn upgrade_model_handle<T: Entity>(
&self, &self,
handle: &WeakModelHandle<T>, handle: &WeakModelHandle<T>,
@ -196,7 +196,7 @@ impl UpgradeModelHandle for WindowContext<'_, '_> {
} }
} }
impl UpgradeViewHandle for WindowContext<'_, '_> { impl UpgradeViewHandle for WindowContext<'_> {
fn upgrade_view_handle<T: View>(&self, handle: &WeakViewHandle<T>) -> Option<ViewHandle<T>> { fn upgrade_view_handle<T: View>(&self, handle: &WeakViewHandle<T>) -> Option<ViewHandle<T>> {
self.app_context.upgrade_view_handle(handle) self.app_context.upgrade_view_handle(handle)
} }
@ -206,10 +206,10 @@ impl UpgradeViewHandle for WindowContext<'_, '_> {
} }
} }
impl<'a: 'b, 'b> WindowContext<'a, 'b> { impl<'a> WindowContext<'a> {
pub fn mutable( pub fn mutable(
app_context: &'a mut AppContext, app_context: &'a mut AppContext,
window: &'b mut Window, window: &'a mut Window,
window_id: usize, window_id: usize,
) -> Self { ) -> Self {
Self { Self {
@ -221,7 +221,7 @@ impl<'a: 'b, 'b> WindowContext<'a, 'b> {
} }
} }
pub fn immutable(app_context: &'a AppContext, window: &'b Window, window_id: usize) -> Self { pub fn immutable(app_context: &'a AppContext, window: &'a Window, window_id: usize) -> Self {
Self { Self {
app_context: Reference::Immutable(app_context), app_context: Reference::Immutable(app_context),
window: Reference::Immutable(window), window: Reference::Immutable(window),

View file

@ -787,6 +787,10 @@ impl Pane {
) -> Option<Task<Result<()>>> { ) -> Option<Task<Result<()>>> {
let pane_handle = workspace.active_pane().clone(); let pane_handle = workspace.active_pane().clone();
let pane = pane_handle.read(cx); let pane = pane_handle.read(cx);
if pane.items.is_empty() {
return None;
}
let active_item_id = pane.items[pane.active_item_index].id(); let active_item_id = pane.items[pane.active_item_index].id();
let task = Self::close_item_by_id(workspace, pane_handle, active_item_id, cx); let task = Self::close_item_by_id(workspace, pane_handle, active_item_id, cx);
@ -2110,6 +2114,19 @@ mod tests {
use gpui::{executor::Deterministic, TestAppContext}; use gpui::{executor::Deterministic, TestAppContext};
use project::FakeFs; use project::FakeFs;
#[gpui::test]
async fn test_remove_active_empty(cx: &mut TestAppContext) {
Settings::test_async(cx);
let fs = FakeFs::new(cx.background());
let project = Project::test(fs, None, cx).await;
let (_, workspace) = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
workspace.update(cx, |workspace, cx| {
assert!(Pane::close_active_item(workspace, &CloseActiveItem, cx).is_none())
});
}
#[gpui::test] #[gpui::test]
async fn test_add_item_with_new_item(cx: &mut TestAppContext) { async fn test_add_item_with_new_item(cx: &mut TestAppContext) {
cx.foreground().forbid_parking(); cx.foreground().forbid_parking();