Skip to content

Commit

Permalink
fix(plugins): various ui fixes (#2731)
Browse files Browse the repository at this point in the history
  • Loading branch information
imsnif authored Aug 26, 2023
1 parent a819e9b commit 2dbee21
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
8 changes: 6 additions & 2 deletions default-plugins/session-manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use session_list::SessionList;
struct State {
session_name: Option<String>,
sessions: SessionList,
selected_index: Option<usize>,
search_term: String,
new_session_name: Option<String>,
colors: Colors,
Expand Down Expand Up @@ -79,7 +78,7 @@ impl ZellijPlugin for State {

impl State {
fn reset_selected_index(&mut self) {
self.selected_index = None;
self.sessions.reset_selected_index();
}
fn handle_key(&mut self, key: Key) -> bool {
let mut should_render = false;
Expand Down Expand Up @@ -186,6 +185,11 @@ impl State {
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();
}
fn update_session_infos(&mut self, session_infos: Vec<SessionInfo>) {
Expand Down
8 changes: 8 additions & 0 deletions default-plugins/session-manager/src/session_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ impl SessionList {
}
}
}
pub fn reset_selected_index(&mut self) {
self.selected_index.reset();
}
}

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

#[derive(Debug)]
Expand Down
5 changes: 0 additions & 5 deletions zellij-server/src/panes/floating_panes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,11 +872,6 @@ impl FloatingPanes {
}
pub fn get_plugin_pane_id(&self, run_plugin: &RunPlugin) -> Option<PaneId> {
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
.iter()
.find(|(_id, s_p)| s_p.invoked_with() == &run)
Expand Down
2 changes: 1 addition & 1 deletion zellij-server/src/panes/plugin_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ impl PluginPane {
));
} else {
messages.push_str(&format!(
"{} {}. {} {}\n",
"{} {}. {} {}",
bold_white.paint("This plugin asks permission to:"),
orange.paint(
permissions
Expand Down
1 change: 1 addition & 0 deletions zellij-server/src/plugins/zellij_exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ fn check_command_permission(
| PluginCommand::FocusPluginPane(..)
| PluginCommand::RenameTerminalPane(..)
| PluginCommand::RenamePluginPane(..)
| PluginCommand::SwitchSession(..)
| PluginCommand::RenameTab(..) => PermissionType::ChangeApplicationState,
_ => return (PermissionStatus::Granted, None),
};
Expand Down

0 comments on commit 2dbee21

Please sign in to comment.