fix(plugins): various ui fixes (#2731)

This commit is contained in:
Aram Drevekenin 2023-08-26 11:06:22 +02:00 committed by GitHub
parent a819e9bf54
commit 2dbee21d74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 8 deletions

View file

@ -15,7 +15,6 @@ use session_list::SessionList;
struct State { struct State {
session_name: Option<String>, session_name: Option<String>,
sessions: SessionList, sessions: SessionList,
selected_index: Option<usize>,
search_term: String, search_term: String,
new_session_name: Option<String>, new_session_name: Option<String>,
colors: Colors, colors: Colors,
@ -79,7 +78,7 @@ impl ZellijPlugin for State {
impl State { impl State {
fn reset_selected_index(&mut self) { fn reset_selected_index(&mut self) {
self.selected_index = None; self.sessions.reset_selected_index();
} }
fn handle_key(&mut self, key: Key) -> bool { fn handle_key(&mut self, key: Key) -> bool {
let mut should_render = false; let mut should_render = false;
@ -186,6 +185,11 @@ impl State {
switch_session_with_focus(&selected_session_name, selected_tab, selected_pane); switch_session_with_focus(&selected_session_name, selected_tab, selected_pane);
} }
} }
self.reset_selected_index();
self.new_session_name = None;
self.search_term.clear();
self.sessions
.update_search_term(&self.search_term, &self.colors);
hide_self(); hide_self();
} }
fn update_session_infos(&mut self, session_infos: Vec<SessionInfo>) { fn update_session_infos(&mut self, session_infos: Vec<SessionInfo>) {

View file

@ -311,6 +311,9 @@ impl SessionList {
} }
} }
} }
pub fn reset_selected_index(&mut self) {
self.selected_index.reset();
}
} }
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default)]
@ -339,6 +342,11 @@ impl SelectedIndex {
_ => {}, _ => {},
} }
} }
pub fn reset(&mut self) {
self.0 = None;
self.1 = None;
self.2 = None;
}
} }
#[derive(Debug)] #[derive(Debug)]

View file

@ -872,11 +872,6 @@ impl FloatingPanes {
} }
pub fn get_plugin_pane_id(&self, run_plugin: &RunPlugin) -> Option<PaneId> { pub fn get_plugin_pane_id(&self, run_plugin: &RunPlugin) -> Option<PaneId> {
let run = Some(Run::Plugin(run_plugin.clone())); let run = Some(Run::Plugin(run_plugin.clone()));
let currently_running_invoked_with: Vec<Option<Run>> = self
.panes
.iter()
.map(|(_, p)| p.invoked_with().clone())
.collect();
self.panes self.panes
.iter() .iter()
.find(|(_id, s_p)| s_p.invoked_with() == &run) .find(|(_id, s_p)| s_p.invoked_with() == &run)

View file

@ -674,7 +674,7 @@ impl PluginPane {
)); ));
} else { } else {
messages.push_str(&format!( messages.push_str(&format!(
"{} {}. {} {}\n", "{} {}. {} {}",
bold_white.paint("This plugin asks permission to:"), bold_white.paint("This plugin asks permission to:"),
orange.paint( orange.paint(
permissions permissions

View file

@ -1143,6 +1143,7 @@ fn check_command_permission(
| PluginCommand::FocusPluginPane(..) | PluginCommand::FocusPluginPane(..)
| PluginCommand::RenameTerminalPane(..) | PluginCommand::RenameTerminalPane(..)
| PluginCommand::RenamePluginPane(..) | PluginCommand::RenamePluginPane(..)
| PluginCommand::SwitchSession(..)
| PluginCommand::RenameTab(..) => PermissionType::ChangeApplicationState, | PluginCommand::RenameTab(..) => PermissionType::ChangeApplicationState,
_ => return (PermissionStatus::Granted, None), _ => return (PermissionStatus::Granted, None),
}; };