Fix right click handler for tabs

Also, some fun test helpers

Co-Authored-By: Mikayla <mikayla@zed.dev>
This commit is contained in:
Conrad Irwin 2024-01-18 12:07:52 -07:00
parent 7b9e7fea4e
commit 920eced1d5
9 changed files with 116 additions and 11 deletions

View file

@ -30,7 +30,7 @@ use std::{
borrow::{Borrow, BorrowMut, Cow},
cell::RefCell,
collections::hash_map::Entry,
fmt::Debug,
fmt::{Debug, Display},
future::Future,
hash::{Hash, Hasher},
marker::PhantomData,
@ -325,6 +325,9 @@ pub(crate) struct Frame {
requested_cursor_style: Option<CursorStyle>,
pub(crate) view_stack: Vec<EntityId>,
pub(crate) reused_views: FxHashSet<EntityId>,
#[cfg(any(test, feature = "test-support"))]
pub(crate) debug_bounds: collections::FxHashMap<String, Bounds<Pixels>>,
}
impl Frame {
@ -348,6 +351,9 @@ impl Frame {
requested_cursor_style: None,
view_stack: Vec::new(),
reused_views: FxHashSet::default(),
#[cfg(any(test, feature = "test-support"))]
debug_bounds: FxHashMap::default(),
}
}
@ -3379,6 +3385,20 @@ pub enum ElementId {
NamedInteger(SharedString, usize),
}
impl Display for ElementId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ElementId::View(entity_id) => write!(f, "view-{}", entity_id)?,
ElementId::Integer(ix) => write!(f, "{}", ix)?,
ElementId::Name(name) => write!(f, "{}", name)?,
ElementId::FocusHandle(__) => write!(f, "FocusHandle")?,
ElementId::NamedInteger(s, i) => write!(f, "{}-{}", s, i)?,
}
Ok(())
}
}
impl ElementId {
pub(crate) fn from_entity_id(entity_id: EntityId) -> Self {
ElementId::View(entity_id)