Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugins): handle race when setting plugin selectable #3651

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions zellij-server/src/screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,7 @@ pub(crate) fn screen_thread_main(
let mut pending_tab_ids: HashSet<usize> = HashSet::new();
let mut pending_tab_switches: HashSet<(usize, ClientId)> = HashSet::new(); // usize is the
// tab_index
let mut pending_events_waiting_for_tab: Vec<ScreenInstruction> = vec![];
let mut pending_events_waiting_for_client: Vec<ScreenInstruction> = vec![];
let mut plugin_loading_message_cache = HashMap::new();
loop {
Expand Down Expand Up @@ -3299,12 +3300,18 @@ pub(crate) fn screen_thread_main(
},
ScreenInstruction::SetSelectable(pid, selectable) => {
let all_tabs = screen.get_tabs_mut();
let mut found_plugin = false;
for tab in all_tabs.values_mut() {
if tab.has_pane_with_pid(&pid) {
tab.set_pane_selectable(pid, selectable);
found_plugin = true;
break;
}
}
if !found_plugin {
pending_events_waiting_for_tab
.push(ScreenInstruction::SetSelectable(pid, selectable));
}
screen.render(None)?;
screen.log_and_report_session_state()?;
},
Expand Down Expand Up @@ -3505,6 +3512,10 @@ pub(crate) fn screen_thread_main(
screen.bus.senders.send_to_screen(event).non_fatal();
}

for event in pending_events_waiting_for_tab.drain(..) {
screen.bus.senders.send_to_screen(event).non_fatal();
}

screen.unblock_input()?;
screen.render(None)?;
// we do this here in order to recover from a race condition on app start
Expand Down
Loading