Skip to content

Commit

Permalink
Fix system.list-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchengxu committed Mar 4, 2024
1 parent 56cdb1d commit 2474894
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/maple_core/src/stdio_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 6 additions & 1 deletion crates/maple_core/src/stdio_server/plugin/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")?;
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/maple_core/src/stdio_server/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down

0 comments on commit 2474894

Please sign in to comment.