diff options
author | Gokul Soumya | 2022-02-08 03:31:24 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-02-08 07:44:39 +0000 |
commit | 5995568c1d23239a230d6e1bcbfc370e5c8cd287 (patch) | |
tree | 65e5712004af4889d95a0fafbb2d484a83b07293 /helix-term/src/compositor.rs | |
parent | 547c3ecd0c72f2b88fa2b3c1321ad9adcb42ee47 (diff) |
Prevent multiple code action popups
Diffstat (limited to 'helix-term/src/compositor.rs')
-rw-r--r-- | helix-term/src/compositor.rs | 10 |
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() } |