mirror of
https://github.com/helix-editor/helix.git
synced 2025-10-06 00:13:28 +02:00
Close prompts when switching windows (#13620)
This commit is contained in:
@@ -136,6 +136,11 @@ impl Compositor {
|
|||||||
Some(self.layers.remove(idx))
|
Some(self.layers.remove(idx))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn remove_type<T: 'static>(&mut self) {
|
||||||
|
let type_name = std::any::type_name::<T>();
|
||||||
|
self.layers
|
||||||
|
.retain(|component| component.type_name() != type_name);
|
||||||
|
}
|
||||||
pub fn handle_event(&mut self, event: &Event, cx: &mut Context) -> bool {
|
pub fn handle_event(&mut self, event: &Event, cx: &mut Context) -> bool {
|
||||||
// If it is a key event, a macro is being recorded, and a macro isn't being replayed,
|
// If it is a key event, a macro is being recorded, and a macro isn't being replayed,
|
||||||
// push the key event to the recording.
|
// push the key event to the recording.
|
||||||
|
@@ -16,6 +16,7 @@ mod auto_save;
|
|||||||
pub mod completion;
|
pub mod completion;
|
||||||
mod diagnostics;
|
mod diagnostics;
|
||||||
mod document_colors;
|
mod document_colors;
|
||||||
|
mod prompt;
|
||||||
mod signature_help;
|
mod signature_help;
|
||||||
mod snippet;
|
mod snippet;
|
||||||
|
|
||||||
@@ -43,5 +44,6 @@ pub fn setup(config: Arc<ArcSwap<Config>>) -> Handlers {
|
|||||||
diagnostics::register_hooks(&handlers);
|
diagnostics::register_hooks(&handlers);
|
||||||
snippet::register_hooks(&handlers);
|
snippet::register_hooks(&handlers);
|
||||||
document_colors::register_hooks(&handlers);
|
document_colors::register_hooks(&handlers);
|
||||||
|
prompt::register_hooks(&handlers);
|
||||||
handlers
|
handlers
|
||||||
}
|
}
|
||||||
|
17
helix-term/src/handlers/prompt.rs
Normal file
17
helix-term/src/handlers/prompt.rs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
use helix_event::register_hook;
|
||||||
|
use helix_view::events::DocumentFocusLost;
|
||||||
|
use helix_view::handlers::Handlers;
|
||||||
|
|
||||||
|
use crate::job::{self};
|
||||||
|
use crate::ui;
|
||||||
|
|
||||||
|
pub(super) fn register_hooks(_handlers: &Handlers) {
|
||||||
|
register_hook!(move |_event: &mut DocumentFocusLost<'_>| {
|
||||||
|
job::dispatch_blocking(move |_, compositor| {
|
||||||
|
if compositor.find::<ui::Prompt>().is_some() {
|
||||||
|
compositor.remove_type::<ui::Prompt>();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Ok(())
|
||||||
|
});
|
||||||
|
}
|
Reference in New Issue
Block a user