From 2474894fea69bba54388634081a7b33821818e91 Mon Sep 17 00:00:00 2001 From: Liu-Cheng Xu Date: Fri, 1 Mar 2024 11:40:52 +0800 Subject: [PATCH] Fix system.list-plugins --- crates/maple_core/src/stdio_server/mod.rs | 2 +- crates/maple_core/src/stdio_server/plugin/system.rs | 7 ++++++- crates/maple_core/src/stdio_server/service.rs | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/maple_core/src/stdio_server/mod.rs b/crates/maple_core/src/stdio_server/mod.rs index da51cc814..ed7bc156f 100644 --- a/crates/maple_core/src/stdio_server/mod.rs +++ b/crates/maple_core/src/stdio_server/mod.rs @@ -375,7 +375,7 @@ impl Backend { self.service_manager.lock().notify_plugins(autocmd_event); } Event::Action((plugin_id, plugin_action)) => { - if plugin_id == "system" && plugin_action.method == "list-plugins" { + if plugin::SystemPlugin::is_list_plugins(plugin_id, &plugin_action) { let lines = self .service_manager .lock() diff --git a/crates/maple_core/src/stdio_server/plugin/system.rs b/crates/maple_core/src/stdio_server/plugin/system.rs index e73d36d5f..0043e2e64 100644 --- a/crates/maple_core/src/stdio_server/plugin/system.rs +++ b/crates/maple_core/src/stdio_server/plugin/system.rs @@ -28,6 +28,10 @@ impl System { Self { vim } } + pub fn is_list_plugins(plugin_id: &str, action: &PluginAction) -> bool { + plugin_id == "system" && action.method == "listPlugins" + } + async fn configure_vim_which_key_map( &self, variable_name: &str, @@ -163,7 +167,8 @@ impl ClapPlugin for System { .exec("execute", format!("edit {}", config_file.display()))?; } SystemAction::ListPlugins => { - unreachable!("action list-plugins has been handled upper level") + self.vim + .echo_warn("action listPlugins should have been handled upper level, please report this as an error")?; } } diff --git a/crates/maple_core/src/stdio_server/service.rs b/crates/maple_core/src/stdio_server/service.rs index 188b0d31f..a66d3dfed 100644 --- a/crates/maple_core/src/stdio_server/service.rs +++ b/crates/maple_core/src/stdio_server/service.rs @@ -448,6 +448,7 @@ impl ServiceManager { pub fn notify_plugin_action(&mut self, plugin_id: PluginId, plugin_action: PluginAction) { if let Entry::Occupied(v) = self.plugins.entry(plugin_id) { if v.get().1.send(PluginEvent::Action(plugin_action)).is_err() { + tracing::error!("plugin {plugin_id} exited"); v.remove_entry(); } }