diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index d3078bce81..596abe9bb6 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -21,6 +21,7 @@ use language::{ use project::{DiagnosticSummary, Project, ProjectPath}; use serde_json::json; use settings::Settings; +use smallvec::SmallVec; use std::{ any::{Any, TypeId}, cmp::Ordering, @@ -579,7 +580,7 @@ impl Item for ProjectDiagnosticsEditor { .update(cx, |editor, cx| editor.git_diff_recalc(project, cx)) } - fn to_item_events(event: &Self::Event) -> Vec { + fn to_item_events(event: &Self::Event) -> SmallVec<[ItemEvent; 2]> { Editor::to_item_events(event) } diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 501306aa19..c52d00b7e3 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -19,6 +19,7 @@ use language::{ use project::{FormatTrigger, Item as _, Project, ProjectPath}; use rpc::proto::{self, update_view}; use settings::Settings; +use smallvec::SmallVec; use std::{ borrow::Cow, cmp::{self, Ordering}, @@ -693,8 +694,8 @@ impl Item for Editor { Task::ready(Ok(())) } - fn to_item_events(event: &Self::Event) -> Vec { - let mut result = Vec::new(); + fn to_item_events(event: &Self::Event) -> SmallVec<[ItemEvent; 2]> { + let mut result = SmallVec::new(); match event { Event::Closed => result.push(ItemEvent::CloseItem), Event::Saved | Event::TitleChanged => { diff --git a/crates/feedback/src/feedback_editor.rs b/crates/feedback/src/feedback_editor.rs index fd61827317..bcef9d0af5 100644 --- a/crates/feedback/src/feedback_editor.rs +++ b/crates/feedback/src/feedback_editor.rs @@ -24,6 +24,7 @@ use serde::Serialize; use workspace::{ item::{Item, ItemHandle}, searchable::{SearchableItem, SearchableItemHandle}, + smallvec::SmallVec, AppState, Workspace, }; @@ -258,8 +259,8 @@ impl Item for FeedbackEditor { self.editor.for_each_project_item(cx, f) } - fn to_item_events(_: &Self::Event) -> Vec { - Vec::new() + fn to_item_events(_: &Self::Event) -> SmallVec<[workspace::item::ItemEvent; 2]> { + SmallVec::new() } fn is_singleton(&self, _: &AppContext) -> bool { diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 71a40685e9..99c73815c9 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -16,6 +16,7 @@ use gpui::{ use menu::Confirm; use project::{search::SearchQuery, Project}; use settings::Settings; +use smallvec::SmallVec; use std::{ any::{Any, TypeId}, mem, @@ -345,11 +346,13 @@ impl Item for ProjectSearchView { .update(cx, |editor, cx| editor.git_diff_recalc(project, cx)) } - fn to_item_events(event: &Self::Event) -> Vec { + fn to_item_events(event: &Self::Event) -> SmallVec<[ItemEvent; 2]> { match event { - ViewEvent::UpdateTab => vec![ItemEvent::UpdateBreadcrumbs, ItemEvent::UpdateTab], + ViewEvent::UpdateTab => { + smallvec::smallvec![ItemEvent::UpdateBreadcrumbs, ItemEvent::UpdateTab] + } ViewEvent::EditorEvent(editor_event) => Editor::to_item_events(editor_event), - _ => Vec::new(), + _ => SmallVec::new(), } } diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index dd5c5fb3b0..65edf1b692 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -643,6 +643,8 @@ impl Terminal { if (new_cursor.line.0 as usize) < term.screen_lines() - 1 { term.grid_mut().reset_region((new_cursor.line + 1)..); } + + cx.emit(Event::Wakeup); } InternalEvent::Scroll(scroll) => { term.scroll_display(*scroll); diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index 847dfc5ee5..cc3025d96e 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -21,6 +21,7 @@ use gpui::{ use project::{LocalWorktree, Project}; use serde::Deserialize; use settings::{Settings, TerminalBlink, WorkingDirectory}; +use smallvec::SmallVec; use smol::Timer; use terminal::{ alacritty_terminal::{ @@ -664,12 +665,12 @@ impl Item for TerminalView { Some(Box::new(handle.clone())) } - fn to_item_events(event: &Self::Event) -> Vec { + fn to_item_events(event: &Self::Event) -> SmallVec<[ItemEvent; 2]> { match event { - Event::BreadcrumbsChanged => vec![ItemEvent::UpdateBreadcrumbs], - Event::TitleChanged | Event::Wakeup => vec![ItemEvent::UpdateTab], - Event::CloseTerminal => vec![ItemEvent::CloseItem], - _ => vec![], + Event::BreadcrumbsChanged => smallvec::smallvec![ItemEvent::UpdateBreadcrumbs], + Event::TitleChanged | Event::Wakeup => smallvec::smallvec![ItemEvent::UpdateTab], + Event::CloseTerminal => smallvec::smallvec![ItemEvent::CloseItem], + _ => smallvec::smallvec![], } } diff --git a/crates/theme_testbench/src/theme_testbench.rs b/crates/theme_testbench/src/theme_testbench.rs index 3cda5d3e51..84ec68e636 100644 --- a/crates/theme_testbench/src/theme_testbench.rs +++ b/crates/theme_testbench/src/theme_testbench.rs @@ -11,6 +11,7 @@ use gpui::{ }; use project::Project; use settings::Settings; +use smallvec::SmallVec; use theme::{ColorScheme, Layer, Style, StyleSet}; use workspace::{ item::{Item, ItemEvent}, @@ -350,8 +351,8 @@ impl Item for ThemeTestbench { gpui::Task::ready(Ok(())) } - fn to_item_events(_: &Self::Event) -> Vec { - Vec::new() + fn to_item_events(_: &Self::Event) -> SmallVec<[ItemEvent; 2]> { + SmallVec::new() } fn serialized_item_kind() -> Option<&'static str> { diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs index b1888bb243..0e28976151 100644 --- a/crates/workspace/src/item.rs +++ b/crates/workspace/src/item.rs @@ -88,7 +88,7 @@ pub trait Item: View { ) -> Task> { Task::ready(Ok(())) } - fn to_item_events(event: &Self::Event) -> Vec; + fn to_item_events(event: &Self::Event) -> SmallVec<[ItemEvent; 2]>; fn should_close_item_on_event(_: &Self::Event) -> bool { false } @@ -723,6 +723,7 @@ pub(crate) mod test { RenderContext, Task, View, ViewContext, ViewHandle, WeakViewHandle, }; use project::{Project, ProjectEntryId, ProjectPath, WorktreeId}; + use smallvec::SmallVec; use std::{any::Any, borrow::Cow, cell::Cell, path::Path}; pub struct TestProjectItem { @@ -985,8 +986,8 @@ pub(crate) mod test { Task::ready(Ok(())) } - fn to_item_events(_: &Self::Event) -> Vec { - vec![ItemEvent::UpdateTab, ItemEvent::Edit] + fn to_item_events(_: &Self::Event) -> SmallVec<[ItemEvent; 2]> { + [ItemEvent::UpdateTab, ItemEvent::Edit].into() } fn serialized_item_kind() -> Option<&'static str> { diff --git a/crates/workspace/src/shared_screen.rs b/crates/workspace/src/shared_screen.rs index b76535f6ed..b3e107c81b 100644 --- a/crates/workspace/src/shared_screen.rs +++ b/crates/workspace/src/shared_screen.rs @@ -13,6 +13,7 @@ use gpui::{ }; use project::Project; use settings::Settings; +use smallvec::SmallVec; use std::{ path::PathBuf, sync::{Arc, Weak}, @@ -177,9 +178,9 @@ impl Item for SharedScreen { Task::ready(Err(anyhow!("Item::reload called on SharedScreen"))) } - fn to_item_events(event: &Self::Event) -> Vec { + fn to_item_events(event: &Self::Event) -> SmallVec<[ItemEvent; 2]> { match event { - Event::Close => vec![ItemEvent::CloseItem], + Event::Close => smallvec::smallvec!(ItemEvent::CloseItem), } } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 9d209c6f1a..7ca3cc7d22 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -14,6 +14,8 @@ pub mod sidebar; mod status_bar; mod toolbar; +pub use smallvec; + use anyhow::{anyhow, Result}; use call::ActiveCall; use client::{