mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-29 21:49:33 +00:00
Format including missing formatting changes from previous PR
This commit is contained in:
parent
16afb3d5b1
commit
c50be72214
2 changed files with 44 additions and 36 deletions
|
@ -1467,7 +1467,11 @@ mod tests {
|
||||||
let (window_id, editor) = cx.add_window(Default::default(), |cx| {
|
let (window_id, editor) = cx.add_window(Default::default(), |cx| {
|
||||||
Editor::new(EditorMode::Full, buffer, None, settings.1, None, cx)
|
Editor::new(EditorMode::Full, buffer, None, settings.1, None, cx)
|
||||||
});
|
});
|
||||||
let element = EditorElement::new(editor.downgrade(), editor.read(cx).style(cx), CursorShape::Bar);
|
let element = EditorElement::new(
|
||||||
|
editor.downgrade(),
|
||||||
|
editor.read(cx).style(cx),
|
||||||
|
CursorShape::Bar,
|
||||||
|
);
|
||||||
|
|
||||||
let layouts = editor.update(cx, |editor, cx| {
|
let layouts = editor.update(cx, |editor, cx| {
|
||||||
let snapshot = editor.snapshot(cx);
|
let snapshot = editor.snapshot(cx);
|
||||||
|
|
|
@ -758,7 +758,8 @@ pub struct MutableAppContext {
|
||||||
next_subscription_id: usize,
|
next_subscription_id: usize,
|
||||||
frame_count: usize,
|
frame_count: usize,
|
||||||
subscriptions: Arc<Mutex<HashMap<usize, BTreeMap<usize, Option<SubscriptionCallback>>>>>,
|
subscriptions: Arc<Mutex<HashMap<usize, BTreeMap<usize, Option<SubscriptionCallback>>>>>,
|
||||||
global_subscriptions: Arc<Mutex<HashMap<TypeId, BTreeMap<usize, Option<GlobalSubscriptionCallback>>>>>,
|
global_subscriptions:
|
||||||
|
Arc<Mutex<HashMap<TypeId, BTreeMap<usize, Option<GlobalSubscriptionCallback>>>>>,
|
||||||
observations: Arc<Mutex<HashMap<usize, BTreeMap<usize, Option<ObservationCallback>>>>>,
|
observations: Arc<Mutex<HashMap<usize, BTreeMap<usize, Option<ObservationCallback>>>>>,
|
||||||
release_observations: Arc<Mutex<HashMap<usize, BTreeMap<usize, ReleaseObservationCallback>>>>,
|
release_observations: Arc<Mutex<HashMap<usize, BTreeMap<usize, ReleaseObservationCallback>>>>,
|
||||||
presenters_and_platform_windows:
|
presenters_and_platform_windows:
|
||||||
|
@ -1726,7 +1727,8 @@ impl MutableAppContext {
|
||||||
if let Some(mut callback) = callback {
|
if let Some(mut callback) = callback {
|
||||||
let alive = callback(payload.as_ref(), self);
|
let alive = callback(payload.as_ref(), self);
|
||||||
if alive {
|
if alive {
|
||||||
match self.subscriptions
|
match self
|
||||||
|
.subscriptions
|
||||||
.lock()
|
.lock()
|
||||||
.entry(entity_id)
|
.entry(entity_id)
|
||||||
.or_default()
|
.or_default()
|
||||||
|
@ -1734,10 +1736,10 @@ impl MutableAppContext {
|
||||||
{
|
{
|
||||||
collections::btree_map::Entry::Vacant(entry) => {
|
collections::btree_map::Entry::Vacant(entry) => {
|
||||||
entry.insert(Some(callback));
|
entry.insert(Some(callback));
|
||||||
},
|
}
|
||||||
collections::btree_map::Entry::Occupied(entry) => {
|
collections::btree_map::Entry::Occupied(entry) => {
|
||||||
entry.remove();
|
entry.remove();
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1752,18 +1754,19 @@ impl MutableAppContext {
|
||||||
for (id, callback) in callbacks {
|
for (id, callback) in callbacks {
|
||||||
if let Some(mut callback) = callback {
|
if let Some(mut callback) = callback {
|
||||||
callback(payload.as_ref(), self);
|
callback(payload.as_ref(), self);
|
||||||
match self.global_subscriptions
|
match self
|
||||||
|
.global_subscriptions
|
||||||
.lock()
|
.lock()
|
||||||
.entry(type_id)
|
.entry(type_id)
|
||||||
.or_default()
|
.or_default()
|
||||||
.entry(id)
|
.entry(id)
|
||||||
{
|
{
|
||||||
collections::btree_map::Entry::Vacant(entry) => {
|
collections::btree_map::Entry::Vacant(entry) => {
|
||||||
entry.insert(Some(callback));
|
entry.insert(Some(callback));
|
||||||
},
|
}
|
||||||
collections::btree_map::Entry::Occupied(entry) => {
|
collections::btree_map::Entry::Occupied(entry) => {
|
||||||
entry.remove();
|
entry.remove();
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1778,18 +1781,19 @@ impl MutableAppContext {
|
||||||
if let Some(mut callback) = callback {
|
if let Some(mut callback) = callback {
|
||||||
let alive = callback(self);
|
let alive = callback(self);
|
||||||
if alive {
|
if alive {
|
||||||
match self.observations
|
match self
|
||||||
|
.observations
|
||||||
.lock()
|
.lock()
|
||||||
.entry(observed_id)
|
.entry(observed_id)
|
||||||
.or_default()
|
.or_default()
|
||||||
.entry(id)
|
.entry(id)
|
||||||
{
|
{
|
||||||
collections::btree_map::Entry::Vacant(entry) => {
|
collections::btree_map::Entry::Vacant(entry) => {
|
||||||
entry.insert(Some(callback));
|
entry.insert(Some(callback));
|
||||||
},
|
}
|
||||||
collections::btree_map::Entry::Occupied(entry) => {
|
collections::btree_map::Entry::Occupied(entry) => {
|
||||||
entry.remove();
|
entry.remove();
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1818,18 +1822,19 @@ impl MutableAppContext {
|
||||||
if let Some(mut callback) = callback {
|
if let Some(mut callback) = callback {
|
||||||
let alive = callback(self);
|
let alive = callback(self);
|
||||||
if alive {
|
if alive {
|
||||||
match self.observations
|
match self
|
||||||
|
.observations
|
||||||
.lock()
|
.lock()
|
||||||
.entry(observed_view_id)
|
.entry(observed_view_id)
|
||||||
.or_default()
|
.or_default()
|
||||||
.entry(id)
|
.entry(id)
|
||||||
{
|
{
|
||||||
collections::btree_map::Entry::Vacant(entry) => {
|
collections::btree_map::Entry::Vacant(entry) => {
|
||||||
entry.insert(Some(callback));
|
entry.insert(Some(callback));
|
||||||
},
|
}
|
||||||
collections::btree_map::Entry::Occupied(entry) => {
|
collections::btree_map::Entry::Occupied(entry) => {
|
||||||
entry.remove();
|
entry.remove();
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3857,18 +3862,21 @@ pub enum Subscription {
|
||||||
Subscription {
|
Subscription {
|
||||||
id: usize,
|
id: usize,
|
||||||
entity_id: usize,
|
entity_id: usize,
|
||||||
subscriptions: Option<Weak<Mutex<HashMap<usize, BTreeMap<usize, Option<SubscriptionCallback>>>>>>,
|
subscriptions:
|
||||||
|
Option<Weak<Mutex<HashMap<usize, BTreeMap<usize, Option<SubscriptionCallback>>>>>>,
|
||||||
},
|
},
|
||||||
GlobalSubscription {
|
GlobalSubscription {
|
||||||
id: usize,
|
id: usize,
|
||||||
type_id: TypeId,
|
type_id: TypeId,
|
||||||
subscriptions:
|
subscriptions: Option<
|
||||||
Option<Weak<Mutex<HashMap<TypeId, BTreeMap<usize, Option<GlobalSubscriptionCallback>>>>>>,
|
Weak<Mutex<HashMap<TypeId, BTreeMap<usize, Option<GlobalSubscriptionCallback>>>>>,
|
||||||
|
>,
|
||||||
},
|
},
|
||||||
Observation {
|
Observation {
|
||||||
id: usize,
|
id: usize,
|
||||||
entity_id: usize,
|
entity_id: usize,
|
||||||
observations: Option<Weak<Mutex<HashMap<usize, BTreeMap<usize, Option<ObservationCallback>>>>>>,
|
observations:
|
||||||
|
Option<Weak<Mutex<HashMap<usize, BTreeMap<usize, Option<ObservationCallback>>>>>>,
|
||||||
},
|
},
|
||||||
ReleaseObservation {
|
ReleaseObservation {
|
||||||
id: usize,
|
id: usize,
|
||||||
|
@ -3914,10 +3922,10 @@ impl Drop for Subscription {
|
||||||
{
|
{
|
||||||
collections::btree_map::Entry::Vacant(entry) => {
|
collections::btree_map::Entry::Vacant(entry) => {
|
||||||
entry.insert(None);
|
entry.insert(None);
|
||||||
},
|
}
|
||||||
collections::btree_map::Entry::Occupied(entry) => {
|
collections::btree_map::Entry::Occupied(entry) => {
|
||||||
entry.remove();
|
entry.remove();
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3927,18 +3935,13 @@ impl Drop for Subscription {
|
||||||
subscriptions,
|
subscriptions,
|
||||||
} => {
|
} => {
|
||||||
if let Some(subscriptions) = subscriptions.as_ref().and_then(Weak::upgrade) {
|
if let Some(subscriptions) = subscriptions.as_ref().and_then(Weak::upgrade) {
|
||||||
match subscriptions
|
match subscriptions.lock().entry(*type_id).or_default().entry(*id) {
|
||||||
.lock()
|
|
||||||
.entry(*type_id)
|
|
||||||
.or_default()
|
|
||||||
.entry(*id)
|
|
||||||
{
|
|
||||||
collections::btree_map::Entry::Vacant(entry) => {
|
collections::btree_map::Entry::Vacant(entry) => {
|
||||||
entry.insert(None);
|
entry.insert(None);
|
||||||
},
|
}
|
||||||
collections::btree_map::Entry::Occupied(entry) => {
|
collections::btree_map::Entry::Occupied(entry) => {
|
||||||
entry.remove();
|
entry.remove();
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3956,10 +3959,10 @@ impl Drop for Subscription {
|
||||||
{
|
{
|
||||||
collections::btree_map::Entry::Vacant(entry) => {
|
collections::btree_map::Entry::Vacant(entry) => {
|
||||||
entry.insert(None);
|
entry.insert(None);
|
||||||
},
|
}
|
||||||
collections::btree_map::Entry::Occupied(entry) => {
|
collections::btree_map::Entry::Occupied(entry) => {
|
||||||
entry.remove();
|
entry.remove();
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4606,8 +4609,10 @@ mod tests {
|
||||||
let events = events.clone();
|
let events = events.clone();
|
||||||
cx.subscribe_global(move |e: &GlobalEvent, _| {
|
cx.subscribe_global(move |e: &GlobalEvent, _| {
|
||||||
events.borrow_mut().push(("Inner", e.clone()));
|
events.borrow_mut().push(("Inner", e.clone()));
|
||||||
}).detach();
|
})
|
||||||
}).detach();
|
.detach();
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
|
@ -4800,7 +4805,6 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(*events.borrow(), [1]);
|
assert_eq!(*events.borrow(), [1]);
|
||||||
|
|
||||||
|
|
||||||
// Global Events
|
// Global Events
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
struct GlobalEvent(u64);
|
struct GlobalEvent(u64);
|
||||||
|
|
Loading…
Reference in a new issue