Restructure event-handling methods in workspace ItemView

This commit is contained in:
Max Brunsfeld
2021-04-07 15:05:16 -07:00
parent a95d33f662
commit ae57178f3e
2 changed files with 20 additions and 37 deletions
+7 -23
View File
@@ -2,11 +2,7 @@ use super::{
buffer, movement, Anchor, Bias, Buffer, BufferElement, DisplayMap, DisplayPoint, Point,
ToOffset, ToPoint,
};
use crate::{
settings::Settings,
watch,
workspace::{self, ItemViewEvent},
};
use crate::{settings::Settings, watch, workspace};
use anyhow::Result;
use futures_core::future::LocalBoxFuture;
use gpui::{
@@ -86,18 +82,6 @@ pub enum SelectAction {
End,
}
// impl workspace::Item for Buffer {
// type View = BufferView;
// fn build_view(
// buffer: ModelHandle<Self>,
// settings: watch::Receiver<Settings>,
// ctx: &mut ViewContext<Self::View>,
// ) -> Self::View {
// BufferView::for_buffer(buffer, settings, ctx)
// }
// }
pub struct BufferView {
handle: WeakViewHandle<Self>,
buffer: ModelHandle<Buffer>,
@@ -1155,12 +1139,12 @@ impl workspace::Item for Buffer {
}
impl workspace::ItemView for BufferView {
fn to_workspace_event(event: &Self::Event) -> Option<ItemViewEvent> {
match event {
Event::Activate => Some(ItemViewEvent::Activated),
Event::Dirtied | Event::Saved => Some(ItemViewEvent::TabStateChanged),
_ => None,
}
fn should_activate_item_on_event(event: &Self::Event) -> bool {
matches!(event, Event::Activate)
}
fn should_update_tab_on_event(event: &Self::Event) -> bool {
matches!(event, Event::Saved | Event::Dirtied)
}
fn title(&self, app: &AppContext) -> std::string::String {