summaryrefslogtreecommitdiff
path: root/helix-term/src/compositor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/compositor.rs')
-rw-r--r--helix-term/src/compositor.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/helix-term/src/compositor.rs b/helix-term/src/compositor.rs
index 321f56a5..dd7ebe1d 100644
--- a/helix-term/src/compositor.rs
+++ b/helix-term/src/compositor.rs
@@ -126,6 +126,16 @@ impl Compositor {
self.layers.push(layer);
}
+ /// Replace a component that has the given `id` with the new layer and if
+ /// no component is found, push the layer normally.
+ pub fn replace_or_push(&mut self, id: &'static str, layer: Box<dyn Component>) {
+ if let Some(component) = self.find_id(id) {
+ *component = layer;
+ } else {
+ self.push(layer)
+ }
+ }
+
pub fn pop(&mut self) -> Option<Box<dyn Component>> {
self.layers.pop()
}