Repository: lapce/lapce
File: lapce-ui/src/tab.rs (Rust)

Code before:
                            ));
                            data.proxy.proxy_rpc.terminal_close(terminal.term_id);
                        }
                        ctx.set_handled();
                    }
                    LapceUICommand::LoadPlugins(volts) => {
                        let plugin = Arc::make_mut(&mut data.plugin);
                        plugin.volts.update_volts(volts);
                    }
                    LapceUICommand::LoadPluginsFailed => {
                        let plugin = Arc::make_mut(&mut data.plugin);
                        plugin.volts.failed();
                    }
                    LapceUICommand::VoltInstalled(volt) => {
                        let plugin = Arc::make_mut(&mut data.plugin);
                        plugin.installed.insert(volt.id(), volt.clone());

                        // if there is a value inside the installing map, remove it from there as soon as it is installed.
                        plugin.installing.remove(&volt.id());
                    }
                    LapceUICommand::VoltInstalling(volt, progress) => {
                        let plugin = Arc::make_mut(&mut data.plugin);

                        if plugin.installing.contains_key(&volt.id()) {
                            let elem = plugin.installing.get_mut(&volt.id());
                            elem.unwrap().set_progress(*progress);
                        } else {
                            plugin.installing.insert(
                                volt.id(),
                                PluginInstallStatus::new(
                                    PluginInstallType::INSTALLATION,
                                    &volt.display_name,
                                ),
                            );
                        }
                    }
                    LapceUICommand::VoltRemoved(volt) => {
                        let plugin = Arc::make_mut(&mut data.plugin);
                        let id = volt.id();
                        plugin.installed.remove(&id);
                        if plugin.disabled.contains(&id) {
                            plugin.disabled.remove(&id);
                            let _ = data.db.save_disabled_volts(
                                plugin.disabled.iter().collect(),
                            );
                        }
                        if plugin.workspace_disabled.contains(&id) {
                            plugin.workspace_disabled.remove(&id);
                            let _ = data.db.save_disabled_volts(
                                plugin.workspace_disabled.iter().collect(),
                            );

Review comment (suggestion):
This can be (most likely) written as
```suggestion
                        if let Some(elem) = plugin.installing.get_mut(&volt.id()) {
                            elem.set_progress(*progress);
```

I believe this is a bit cleaner.

Code after:
                                ),
                                Target::Widget(terminal.split_id),
                            ));
                            data.proxy.proxy_rpc.terminal_close(terminal.term_id);
                        }
                        ctx.set_handled();
                    }
                    LapceUICommand::LoadPlugins(volts) => {
                        let plugin = Arc::make_mut(&mut data.plugin);
                        plugin.volts.update_volts(volts);
                    }
                    LapceUICommand::LoadPluginsFailed => {
                        let plugin = Arc::make_mut(&mut data.plugin);
                        plugin.volts.failed();
                    }
                    LapceUICommand::VoltInstalled(volt, only_installing) => {
                        let plugin = Arc::make_mut(&mut data.plugin);

                        // if there is a value inside the installing map, remove it from there as soon as it is installed.
                        plugin.installing.remove(&volt.id());

                        if !(*only_installing) {
                            plugin.installed.insert(volt.id(), volt.clone());
                        }
                    }
                    LapceUICommand::VoltInstalling(volt, error) => {
                        let plugin = Arc::make_mut(&mut data.plugin);

                        if let Some(elem) = plugin.installing.get_mut(&volt.id()) {
                            if !error.is_empty() {
                                elem.set_error(error);
                            }
                        } else {
                            plugin.installing.insert(
                                volt.id(),
                                PluginInstallStatus::new(
                                    PluginInstallType::Installation,
                                    &volt.display_name,
                                    error.to_string(),
                                ),
                            );
                        }
                    }
                    LapceUICommand::VoltRemoving(volt, error) => {
                        let plugin = Arc::make_mut(&mut data.plugin);

                        if let Some(elem) = plugin.installing.get_mut(&volt.id()) {
                            if !error.is_empty() {
                                elem.set_error(error);
                            }
                        } else {