Avoid adding the same entry when concurrently opening it more than once
This commit is contained in:
@@ -5,7 +5,7 @@ use gpui::{
|
||||
elements::*,
|
||||
geometry::{rect::RectF, vector::vec2f},
|
||||
keymap::Binding,
|
||||
AppContext, Border, Entity, MutableAppContext, Quad, View, ViewContext,
|
||||
AppContext, Border, Entity, MutableAppContext, Quad, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use postage::watch;
|
||||
use std::{cmp, path::Path, sync::Arc};
|
||||
@@ -382,3 +382,17 @@ impl View for Pane {
|
||||
self.focus_active_item(cx);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait PaneHandle {
|
||||
fn add_item_view(&self, item: Box<dyn ItemViewHandle>, cx: &mut MutableAppContext);
|
||||
}
|
||||
|
||||
impl PaneHandle for ViewHandle<Pane> {
|
||||
fn add_item_view(&self, item: Box<dyn ItemViewHandle>, cx: &mut MutableAppContext) {
|
||||
item.set_parent_pane(self, cx);
|
||||
self.update(cx, |pane, cx| {
|
||||
let item_idx = pane.add_item(item, cx);
|
||||
pane.activate_item(item_idx, cx);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user