refactor(messaging): reduce extraneous cross-thread messaging (#1996)

* refactor(messaging): reduce extraneous cross-thread messaging

* style(fmt): rustfmt
This commit is contained in:
Aram Drevekenin 2022-12-06 22:29:57 +01:00 committed by GitHub
parent a6f7756296
commit b1ab4eac10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 758 additions and 969 deletions

View file

@ -404,11 +404,11 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
.unwrap(); .unwrap();
session_data session_data
.senders .senders
.send_to_plugin(PluginInstruction::Update( .send_to_plugin(PluginInstruction::Update(vec![(
None, None,
Some(client_id), Some(client_id),
Event::ModeUpdate(mode_info), Event::ModeUpdate(mode_info),
)) )]))
.unwrap(); .unwrap();
send_to_client!( send_to_client!(
client_id, client_id,

View file

@ -378,20 +378,20 @@ impl Pane for PluginPane {
} }
fn scroll_up(&mut self, count: usize, client_id: ClientId) { fn scroll_up(&mut self, count: usize, client_id: ClientId) {
self.send_plugin_instructions self.send_plugin_instructions
.send(PluginInstruction::Update( .send(PluginInstruction::Update(vec![(
Some(self.pid), Some(self.pid),
Some(client_id), Some(client_id),
Event::Mouse(Mouse::ScrollUp(count)), Event::Mouse(Mouse::ScrollUp(count)),
)) )]))
.unwrap(); .unwrap();
} }
fn scroll_down(&mut self, count: usize, client_id: ClientId) { fn scroll_down(&mut self, count: usize, client_id: ClientId) {
self.send_plugin_instructions self.send_plugin_instructions
.send(PluginInstruction::Update( .send(PluginInstruction::Update(vec![(
Some(self.pid), Some(self.pid),
Some(client_id), Some(client_id),
Event::Mouse(Mouse::ScrollDown(count)), Event::Mouse(Mouse::ScrollDown(count)),
)) )]))
.unwrap(); .unwrap();
} }
fn clear_scroll(&mut self) { fn clear_scroll(&mut self) {
@ -399,29 +399,29 @@ impl Pane for PluginPane {
} }
fn start_selection(&mut self, start: &Position, client_id: ClientId) { fn start_selection(&mut self, start: &Position, client_id: ClientId) {
self.send_plugin_instructions self.send_plugin_instructions
.send(PluginInstruction::Update( .send(PluginInstruction::Update(vec![(
Some(self.pid), Some(self.pid),
Some(client_id), Some(client_id),
Event::Mouse(Mouse::LeftClick(start.line.0, start.column.0)), Event::Mouse(Mouse::LeftClick(start.line.0, start.column.0)),
)) )]))
.unwrap(); .unwrap();
} }
fn update_selection(&mut self, position: &Position, client_id: ClientId) { fn update_selection(&mut self, position: &Position, client_id: ClientId) {
self.send_plugin_instructions self.send_plugin_instructions
.send(PluginInstruction::Update( .send(PluginInstruction::Update(vec![(
Some(self.pid), Some(self.pid),
Some(client_id), Some(client_id),
Event::Mouse(Mouse::Hold(position.line.0, position.column.0)), Event::Mouse(Mouse::Hold(position.line.0, position.column.0)),
)) )]))
.unwrap(); .unwrap();
} }
fn end_selection(&mut self, end: &Position, client_id: ClientId) { fn end_selection(&mut self, end: &Position, client_id: ClientId) {
self.send_plugin_instructions self.send_plugin_instructions
.send(PluginInstruction::Update( .send(PluginInstruction::Update(vec![(
Some(self.pid), Some(self.pid),
Some(client_id), Some(client_id),
Event::Mouse(Mouse::Release(end.line(), end.column())), Event::Mouse(Mouse::Release(end.line(), end.column())),
)) )]))
.unwrap(); .unwrap();
} }
fn is_scrolled(&self) -> bool { fn is_scrolled(&self) -> bool {
@ -462,11 +462,11 @@ impl Pane for PluginPane {
} }
fn handle_right_click(&mut self, to: &Position, client_id: ClientId) { fn handle_right_click(&mut self, to: &Position, client_id: ClientId) {
self.send_plugin_instructions self.send_plugin_instructions
.send(PluginInstruction::Update( .send(PluginInstruction::Update(vec![(
Some(self.pid), Some(self.pid),
Some(client_id), Some(client_id),
Event::Mouse(Mouse::RightClick(to.line.0, to.column.0)), Event::Mouse(Mouse::RightClick(to.line.0, to.column.0)),
)) )]))
.unwrap(); .unwrap();
} }
} }

View file

@ -21,9 +21,9 @@ use zellij_utils::{
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum PluginInstruction { pub enum PluginInstruction {
Load(RunPlugin, usize, ClientId, Size), // plugin metadata, tab_index, client_ids Load(RunPlugin, usize, ClientId, Size), // plugin metadata, tab_index, client_ids
Update(Option<u32>, Option<ClientId>, Event), // Focused plugin / broadcast, client_id, event data Update(Vec<(Option<u32>, Option<ClientId>, Event)>), // Focused plugin / broadcast, client_id, event data
Unload(u32), // plugin_id Unload(u32), // plugin_id
Resize(u32, usize, usize), // plugin_id, columns, rows Resize(u32, usize, usize), // plugin_id, columns, rows
AddClient(ClientId), AddClient(ClientId),
RemoveClient(ClientId), RemoveClient(ClientId),
NewTab( NewTab(
@ -73,8 +73,8 @@ pub(crate) fn plugin_thread_main(
PluginInstruction::Load(run, tab_index, client_id, size) => { PluginInstruction::Load(run, tab_index, client_id, size) => {
wasm_bridge.load_plugin(&run, tab_index, size, client_id)?; wasm_bridge.load_plugin(&run, tab_index, size, client_id)?;
}, },
PluginInstruction::Update(pid, cid, event) => { PluginInstruction::Update(updates) => {
wasm_bridge.update_plugins(pid, cid, event)?; wasm_bridge.update_plugins(updates)?;
}, },
PluginInstruction::Unload(pid) => { PluginInstruction::Unload(pid) => {
wasm_bridge.unload_plugin(pid)?; wasm_bridge.unload_plugin(pid)?;

View file

@ -398,6 +398,7 @@ impl WasmBridge {
} }
pub fn resize_plugin(&mut self, pid: u32, new_columns: usize, new_rows: usize) -> Result<()> { pub fn resize_plugin(&mut self, pid: u32, new_columns: usize, new_rows: usize) -> Result<()> {
let err_context = || format!("failed to resize plugin {pid}"); let err_context = || format!("failed to resize plugin {pid}");
let mut plugin_bytes = vec![];
for ((plugin_id, client_id), (instance, plugin_env, (current_rows, current_columns))) in for ((plugin_id, client_id), (instance, plugin_env, (current_rows, current_columns))) in
self.plugin_map.iter_mut() self.plugin_map.iter_mut()
{ {
@ -418,84 +419,90 @@ impl WasmBridge {
]) ])
.with_context(err_context)?; .with_context(err_context)?;
let rendered_bytes = wasi_read_string(&plugin_env.wasi_env); let rendered_bytes = wasi_read_string(&plugin_env.wasi_env);
drop(self.senders.send_to_screen(ScreenInstruction::PluginBytes( plugin_bytes.push((*plugin_id, *client_id, rendered_bytes.as_bytes().to_vec()));
*plugin_id,
*client_id,
rendered_bytes.as_bytes().to_vec(),
)));
} }
} }
let _ = self
.senders
.send_to_screen(ScreenInstruction::PluginBytes(plugin_bytes));
Ok(()) Ok(())
} }
pub fn update_plugins( pub fn update_plugins(
&mut self, &mut self,
pid: Option<u32>, mut updates: Vec<(Option<u32>, Option<ClientId>, Event)>,
cid: Option<ClientId>,
event: Event,
) -> Result<()> { ) -> Result<()> {
let err_context = || { let err_context = || {
if *DEBUG_MODE.get().unwrap_or(&true) { if *DEBUG_MODE.get().unwrap_or(&true) {
format!("failed to update plugin state with event: {event:#?}") format!("failed to update plugin state")
} else { } else {
"failed to update plugin state".to_string() "failed to update plugin state".to_string()
} }
}; };
for (&(plugin_id, client_id), (instance, plugin_env, (rows, columns))) in &self.plugin_map { let mut plugin_bytes = vec![];
let subs = plugin_env for (pid, cid, event) in updates.drain(..) {
.subscriptions for (&(plugin_id, client_id), (instance, plugin_env, (rows, columns))) in
.lock() &self.plugin_map
.to_anyhow()
.with_context(err_context)?;
// FIXME: This is very janky... Maybe I should write my own macro for Event -> EventType?
let event_type = EventType::from_str(&event.to_string()).with_context(err_context)?;
if subs.contains(&event_type)
&& ((pid.is_none() && cid.is_none())
|| (pid.is_none() && cid == Some(client_id))
|| (cid.is_none() && pid == Some(plugin_id))
|| (cid == Some(client_id) && pid == Some(plugin_id)))
{ {
let update = instance let subs = plugin_env
.exports .subscriptions
.get_function("update") .lock()
.to_anyhow()
.with_context(err_context)?; .with_context(err_context)?;
wasi_write_object(&plugin_env.wasi_env, &event); // FIXME: This is very janky... Maybe I should write my own macro for Event -> EventType?
let update_return = update.call(&[]).or_else::<anyError, _>(|e| { let event_type =
match e.downcast::<serde_json::Error>() { EventType::from_str(&event.to_string()).with_context(err_context)?;
Ok(_) => panic!( if subs.contains(&event_type)
"{}", && ((pid.is_none() && cid.is_none())
anyError::new(VersionMismatchError::new( || (pid.is_none() && cid == Some(client_id))
VERSION, || (cid.is_none() && pid == Some(plugin_id))
"Unavailable", || (cid == Some(client_id) && pid == Some(plugin_id)))
&plugin_env.plugin.path, {
plugin_env.plugin.is_builtin(), let update = instance
))
),
Err(e) => Err(e).with_context(err_context),
}
})?;
let should_render = match update_return.get(0) {
Some(Value::I32(n)) => *n == 1,
_ => false,
};
if *rows > 0 && *columns > 0 && should_render {
let render = instance
.exports .exports
.get_function("render") .get_function("update")
.with_context(err_context)?; .with_context(err_context)?;
render wasi_write_object(&plugin_env.wasi_env, &event);
.call(&[Value::I32(*rows as i32), Value::I32(*columns as i32)]) let update_return = update.call(&[]).or_else::<anyError, _>(|e| {
.with_context(err_context)?; match e.downcast::<serde_json::Error>() {
let rendered_bytes = wasi_read_string(&plugin_env.wasi_env); Ok(_) => panic!(
drop(self.senders.send_to_screen(ScreenInstruction::PluginBytes( "{}",
plugin_id, anyError::new(VersionMismatchError::new(
client_id, VERSION,
rendered_bytes.as_bytes().to_vec(), "Unavailable",
))); &plugin_env.plugin.path,
plugin_env.plugin.is_builtin(),
))
),
Err(e) => Err(e).with_context(err_context),
}
})?;
let should_render = match update_return.get(0) {
Some(Value::I32(n)) => *n == 1,
_ => false,
};
if *rows > 0 && *columns > 0 && should_render {
let render = instance
.exports
.get_function("render")
.with_context(err_context)?;
render
.call(&[Value::I32(*rows as i32), Value::I32(*columns as i32)])
.with_context(err_context)?;
let rendered_bytes = wasi_read_string(&plugin_env.wasi_env);
plugin_bytes.push((
plugin_id,
client_id,
rendered_bytes.as_bytes().to_vec(),
));
}
} }
} }
} }
let _ = self
.senders
.send_to_screen(ScreenInstruction::PluginBytes(plugin_bytes));
Ok(()) Ok(())
} }
pub fn remove_client(&mut self, client_id: ClientId) { pub fn remove_client(&mut self, client_id: ClientId) {
@ -673,11 +680,11 @@ fn host_set_timeout(plugin_env: &PluginEnv, secs: f64) {
send_plugin_instructions send_plugin_instructions
.unwrap() .unwrap()
.send(PluginInstruction::Update( .send(PluginInstruction::Update(vec![(
update_target, update_target,
Some(client_id), Some(client_id),
Event::Timer(elapsed_time), Event::Timer(elapsed_time),
)) )]))
.unwrap(); .unwrap();
}); });
} }

View file

@ -39,11 +39,11 @@ pub(crate) fn route_action(
_ => { _ => {
session session
.senders .senders
.send_to_plugin(PluginInstruction::Update( .send_to_plugin(PluginInstruction::Update(vec![(
None, None,
Some(client_id), Some(client_id),
Event::InputReceived, Event::InputReceived,
)) )]))
.with_context(err_context)?; .with_context(err_context)?;
}, },
} }
@ -84,11 +84,11 @@ pub(crate) fn route_action(
// TODO: Need access to `ClientAttributes` here // TODO: Need access to `ClientAttributes` here
session session
.senders .senders
.send_to_plugin(PluginInstruction::Update( .send_to_plugin(PluginInstruction::Update(vec![(
None, None,
Some(client_id), Some(client_id),
Event::ModeUpdate(get_mode_info(mode, attrs, session.capabilities)), Event::ModeUpdate(get_mode_info(mode, attrs, session.capabilities)),
)) )]))
.with_context(err_context)?; .with_context(err_context)?;
session session
.senders .senders
@ -314,11 +314,11 @@ pub(crate) fn route_action(
let attrs = &session.client_attributes; let attrs = &session.client_attributes;
session session
.senders .senders
.send_to_plugin(PluginInstruction::Update( .send_to_plugin(PluginInstruction::Update(vec![(
None, None,
None, None,
Event::ModeUpdate(get_mode_info(input_mode, attrs, session.capabilities)), Event::ModeUpdate(get_mode_info(input_mode, attrs, session.capabilities)),
)) )]))
.with_context(err_context)?; .with_context(err_context)?;
session session
.senders .senders

View file

@ -122,7 +122,7 @@ type HoldForCommand = Option<RunCommand>;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum ScreenInstruction { pub enum ScreenInstruction {
PtyBytes(u32, VteBytes), PtyBytes(u32, VteBytes),
PluginBytes(u32, ClientId, VteBytes), // u32 is plugin_id PluginBytes(Vec<(u32, ClientId, VteBytes)>), // u32 is plugin_id
Render, Render,
NewPane( NewPane(
PaneId, PaneId,
@ -1019,6 +1019,7 @@ impl Screen {
} }
pub fn update_tabs(&self) -> Result<()> { pub fn update_tabs(&self) -> Result<()> {
let mut plugin_updates = vec![];
for (client_id, active_tab_index) in self.active_tab_indices.iter() { for (client_id, active_tab_index) in self.active_tab_indices.iter() {
let mut tab_data = vec![]; let mut tab_data = vec![];
for tab in self.tabs.values() { for tab in self.tabs.values() {
@ -1045,15 +1046,12 @@ impl Screen {
other_focused_clients, other_focused_clients,
}); });
} }
self.bus plugin_updates.push((None, Some(*client_id), Event::TabUpdate(tab_data)));
.senders
.send_to_plugin(PluginInstruction::Update(
None,
Some(*client_id),
Event::TabUpdate(tab_data),
))
.context("failed to update tabs")?;
} }
self.bus
.senders
.send_to_plugin(PluginInstruction::Update(plugin_updates))
.context("failed to update tabs")?;
Ok(()) Ok(())
} }
@ -1328,13 +1326,15 @@ pub(crate) fn screen_thread_main(
} }
} }
}, },
ScreenInstruction::PluginBytes(pid, client_id, vte_bytes) => { ScreenInstruction::PluginBytes(mut plugin_bytes) => {
let all_tabs = screen.get_tabs_mut(); for (pid, client_id, vte_bytes) in plugin_bytes.drain(..) {
for tab in all_tabs.values_mut() { let all_tabs = screen.get_tabs_mut();
if tab.has_plugin(pid) { for tab in all_tabs.values_mut() {
tab.handle_plugin_bytes(pid, client_id, vte_bytes) if tab.has_plugin(pid) {
.context("failed to process plugin bytes")?; tab.handle_plugin_bytes(pid, client_id, vte_bytes)
break; .context("failed to process plugin bytes")?;
break;
}
} }
} }
screen.render()?; screen.render()?;

View file

@ -683,21 +683,14 @@ impl Tab {
pub fn update_input_modes(&mut self) -> Result<()> { pub fn update_input_modes(&mut self) -> Result<()> {
// this updates all plugins with the client's input mode // this updates all plugins with the client's input mode
let mode_infos = self.mode_info.borrow(); let mode_infos = self.mode_info.borrow();
let mut plugin_updates = vec![];
for client_id in self.connected_clients.borrow().iter() { for client_id in self.connected_clients.borrow().iter() {
let mode_info = mode_infos.get(client_id).unwrap_or(&self.default_mode_info); let mode_info = mode_infos.get(client_id).unwrap_or(&self.default_mode_info);
self.senders plugin_updates.push((None, Some(*client_id), Event::ModeUpdate(mode_info.clone())));
.send_to_plugin(PluginInstruction::Update(
None,
Some(*client_id),
Event::ModeUpdate(mode_info.clone()),
))
.with_context(|| {
format!(
"failed to update plugins with mode info {:?}",
mode_info.mode
)
})?;
} }
self.senders
.send_to_plugin(PluginInstruction::Update(plugin_updates))
.with_context(|| format!("failed to update plugins with mode info"))?;
Ok(()) Ok(())
} }
pub fn add_client(&mut self, client_id: ClientId, mode_info: Option<ModeInfo>) -> Result<()> { pub fn add_client(&mut self, client_id: ClientId, mode_info: Option<ModeInfo>) -> Result<()> {
@ -742,8 +735,7 @@ impl Tab {
); );
} }
self.set_force_render(); self.set_force_render();
self.update_input_modes() Ok(())
.with_context(|| format!("failed to add client {client_id} to tab"))
} }
pub fn change_mode_info(&mut self, mode_info: ModeInfo, client_id: ClientId) { pub fn change_mode_info(&mut self, mode_info: ModeInfo, client_id: ClientId) {
@ -1357,11 +1349,13 @@ impl Tab {
} }
}, },
PaneId::Plugin(pid) => { PaneId::Plugin(pid) => {
let mut plugin_updates = vec![];
for key in parse_keys(&input_bytes) { for key in parse_keys(&input_bytes) {
self.senders plugin_updates.push((Some(pid), None, Event::Key(key)));
.send_to_plugin(PluginInstruction::Update(Some(pid), None, Event::Key(key)))
.with_context(err_context)?;
} }
self.senders
.send_to_plugin(PluginInstruction::Update(plugin_updates))
.with_context(err_context)?;
}, },
} }
Ok(should_update_ui) Ok(should_update_ui)
@ -2633,11 +2627,11 @@ impl Tab {
format!("failed to write selection to clipboard for client {client_id}") format!("failed to write selection to clipboard for client {client_id}")
})?; })?;
self.senders self.senders
.send_to_plugin(PluginInstruction::Update( .send_to_plugin(PluginInstruction::Update(vec![(
None, None,
None, None,
Event::CopyToClipboard(self.clipboard_provider.as_copy_destination()), Event::CopyToClipboard(self.clipboard_provider.as_copy_destination()),
)) )]))
.with_context(|| { .with_context(|| {
format!("failed to inform plugins about copy selection for client {client_id}") format!("failed to inform plugins about copy selection for client {client_id}")
}) })
@ -2677,7 +2671,11 @@ impl Tab {
}, },
}; };
self.senders self.senders
.send_to_plugin(PluginInstruction::Update(None, None, clipboard_event)) .send_to_plugin(PluginInstruction::Update(vec![(
None,
None,
clipboard_event,
)]))
.context("failed to notify plugins about new clipboard event") .context("failed to notify plugins about new clipboard event")
.non_fatal(); .non_fatal();
@ -2712,15 +2710,13 @@ impl Tab {
PaneId::Plugin(pid) => Some(pid), PaneId::Plugin(pid) => Some(pid),
_ => None, _ => None,
}); });
let mut plugin_updates = vec![];
for pid in pids_in_this_tab { for pid in pids_in_this_tab {
self.senders plugin_updates.push((Some(*pid), None, Event::Visible(visible)));
.send_to_plugin(PluginInstruction::Update(
Some(*pid),
None,
Event::Visible(visible),
))
.with_context(|| format!("failed to set visibility of tab to {visible}"))?;
} }
self.senders
.send_to_plugin(PluginInstruction::Update(plugin_updates))
.with_context(|| format!("failed to set visibility of tab to {visible}"))?;
Ok(()) Ok(())
} }

View file

@ -1,6 +1,6 @@
--- ---
source: zellij-server/src/./unit/screen_tests.rs source: zellij-server/src/./unit/screen_tests.rs
assertion_line: 2346 assertion_line: 2366
expression: "format!(\"{}\", snapshot)" expression: "format!(\"{}\", snapshot)"
--- ---
00 (C): ┌ Pane #1 ─────────────────────────────────────────────────────────────────────┐ 00 (C): ┌ Pane #1 ─────────────────────────────────────────────────────────────────────┐

View file

@ -1,22 +1,30 @@
--- ---
source: zellij-server/src/./unit/screen_tests.rs source: zellij-server/src/./unit/screen_tests.rs
assertion_line: 2506 assertion_line: 2511
expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())" expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
--- ---
[ [
Update( Update(
None, [
Some( (
10, None,
), Some(
InputReceived, 10,
),
InputReceived,
),
],
), ),
Update( Update(
None, [
Some( (
10, None,
), Some(
InputReceived, 10,
),
InputReceived,
),
],
), ),
NewTab( NewTab(
None, None,
@ -58,176 +66,111 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
1, 1,
), ),
Update( Update(
None, [
Some( (
1, None,
), Some(
ModeUpdate( 1,
ModeInfo { ),
mode: Normal, ModeUpdate(
keybinds: [], ModeInfo {
style: Style { mode: Normal,
colors: Palette { keybinds: [],
source: Default, style: Style {
theme_hue: Dark, colors: Palette {
fg: EightBit( source: Default,
0, theme_hue: Dark,
), fg: EightBit(
bg: EightBit( 0,
0, ),
), bg: EightBit(
black: EightBit( 0,
0, ),
), black: EightBit(
red: EightBit( 0,
0, ),
), red: EightBit(
green: EightBit( 0,
0, ),
), green: EightBit(
yellow: EightBit( 0,
0, ),
), yellow: EightBit(
blue: EightBit( 0,
0, ),
), blue: EightBit(
magenta: EightBit( 0,
0, ),
), magenta: EightBit(
cyan: EightBit( 0,
0, ),
), cyan: EightBit(
white: EightBit( 0,
0, ),
), white: EightBit(
orange: EightBit( 0,
0, ),
), orange: EightBit(
gray: EightBit( 0,
0, ),
), gray: EightBit(
purple: EightBit( 0,
0, ),
), purple: EightBit(
gold: EightBit( 0,
0, ),
), gold: EightBit(
silver: EightBit( 0,
0, ),
), silver: EightBit(
pink: EightBit( 0,
0, ),
), pink: EightBit(
brown: EightBit( 0,
0, ),
brown: EightBit(
0,
),
},
rounded_corners: false,
},
capabilities: PluginCapabilities {
arrow_fonts: false,
},
session_name: Some(
"zellij-test",
), ),
}, },
rounded_corners: false,
},
capabilities: PluginCapabilities {
arrow_fonts: false,
},
session_name: Some(
"zellij-test",
), ),
}, ),
), ],
), ),
Update( Update(
None, [],
Some(
1,
),
ModeUpdate(
ModeInfo {
mode: Normal,
keybinds: [],
style: Style {
colors: Palette {
source: Default,
theme_hue: Dark,
fg: EightBit(
0,
),
bg: EightBit(
0,
),
black: EightBit(
0,
),
red: EightBit(
0,
),
green: EightBit(
0,
),
yellow: EightBit(
0,
),
blue: EightBit(
0,
),
magenta: EightBit(
0,
),
cyan: EightBit(
0,
),
white: EightBit(
0,
),
orange: EightBit(
0,
),
gray: EightBit(
0,
),
purple: EightBit(
0,
),
gold: EightBit(
0,
),
silver: EightBit(
0,
),
pink: EightBit(
0,
),
brown: EightBit(
0,
),
},
rounded_corners: false,
},
capabilities: PluginCapabilities {
arrow_fonts: false,
},
session_name: Some(
"zellij-test",
),
},
),
), ),
Update( Update(
None, [
Some( (
1, None,
), Some(
TabUpdate( 1,
[ ),
TabInfo { TabUpdate(
position: 0, [
name: "Tab #1", TabInfo {
active: true, position: 0,
panes_to_hide: 0, name: "Tab #1",
is_fullscreen_active: false, active: true,
is_sync_panes_active: false, panes_to_hide: 0,
are_floating_panes_visible: false, is_fullscreen_active: false,
other_focused_clients: [], is_sync_panes_active: false,
}, are_floating_panes_visible: false,
], other_focused_clients: [],
), },
],
),
),
],
), ),
NewTab( NewTab(
None, None,
@ -269,246 +212,192 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
1, 1,
), ),
Update( Update(
None, [],
Some( ),
1, Update(
), [
ModeUpdate( (
ModeInfo { None,
mode: Normal, Some(
keybinds: [], 1,
style: Style { ),
colors: Palette { ModeUpdate(
source: Default, ModeInfo {
theme_hue: Dark, mode: Normal,
fg: EightBit( keybinds: [],
0, style: Style {
), colors: Palette {
bg: EightBit( source: Default,
0, theme_hue: Dark,
), fg: EightBit(
black: EightBit( 0,
0, ),
), bg: EightBit(
red: EightBit( 0,
0, ),
), black: EightBit(
green: EightBit( 0,
0, ),
), red: EightBit(
yellow: EightBit( 0,
0, ),
), green: EightBit(
blue: EightBit( 0,
0, ),
), yellow: EightBit(
magenta: EightBit( 0,
0, ),
), blue: EightBit(
cyan: EightBit( 0,
0, ),
), magenta: EightBit(
white: EightBit( 0,
0, ),
), cyan: EightBit(
orange: EightBit( 0,
0, ),
), white: EightBit(
gray: EightBit( 0,
0, ),
), orange: EightBit(
purple: EightBit( 0,
0, ),
), gray: EightBit(
gold: EightBit( 0,
0, ),
), purple: EightBit(
silver: EightBit( 0,
0, ),
), gold: EightBit(
pink: EightBit( 0,
0, ),
), silver: EightBit(
brown: EightBit( 0,
0, ),
pink: EightBit(
0,
),
brown: EightBit(
0,
),
},
rounded_corners: false,
},
capabilities: PluginCapabilities {
arrow_fonts: false,
},
session_name: Some(
"zellij-test",
), ),
}, },
rounded_corners: false,
},
capabilities: PluginCapabilities {
arrow_fonts: false,
},
session_name: Some(
"zellij-test",
), ),
}, ),
), ],
), ),
Update( Update(
None, [],
Some( ),
1, Update(
), [
ModeUpdate( (
ModeInfo { None,
mode: Normal, Some(
keybinds: [], 1,
style: Style {
colors: Palette {
source: Default,
theme_hue: Dark,
fg: EightBit(
0,
),
bg: EightBit(
0,
),
black: EightBit(
0,
),
red: EightBit(
0,
),
green: EightBit(
0,
),
yellow: EightBit(
0,
),
blue: EightBit(
0,
),
magenta: EightBit(
0,
),
cyan: EightBit(
0,
),
white: EightBit(
0,
),
orange: EightBit(
0,
),
gray: EightBit(
0,
),
purple: EightBit(
0,
),
gold: EightBit(
0,
),
silver: EightBit(
0,
),
pink: EightBit(
0,
),
brown: EightBit(
0,
),
},
rounded_corners: false,
},
capabilities: PluginCapabilities {
arrow_fonts: false,
},
session_name: Some(
"zellij-test",
), ),
}, TabUpdate(
), [
TabInfo {
position: 0,
name: "Tab #1",
active: false,
panes_to_hide: 0,
is_fullscreen_active: false,
is_sync_panes_active: false,
are_floating_panes_visible: false,
other_focused_clients: [],
},
TabInfo {
position: 1,
name: "Tab #2",
active: true,
panes_to_hide: 0,
is_fullscreen_active: false,
is_sync_panes_active: false,
are_floating_panes_visible: false,
other_focused_clients: [],
},
],
),
),
],
), ),
Update( Update(
None, [
Some( (
1, None,
), Some(
TabUpdate( 1,
[ ),
TabInfo { TabUpdate(
position: 0, [
name: "Tab #1", TabInfo {
active: false, position: 0,
panes_to_hide: 0, name: "Tab #1",
is_fullscreen_active: false, active: false,
is_sync_panes_active: false, panes_to_hide: 0,
are_floating_panes_visible: false, is_fullscreen_active: false,
other_focused_clients: [], is_sync_panes_active: false,
}, are_floating_panes_visible: false,
TabInfo { other_focused_clients: [],
position: 1, },
name: "Tab #2", TabInfo {
active: true, position: 1,
panes_to_hide: 0, name: "",
is_fullscreen_active: false, active: true,
is_sync_panes_active: false, panes_to_hide: 0,
are_floating_panes_visible: false, is_fullscreen_active: false,
other_focused_clients: [], is_sync_panes_active: false,
}, are_floating_panes_visible: false,
], other_focused_clients: [],
), },
],
),
),
],
), ),
Update( Update(
None, [
Some( (
1, None,
), Some(
TabUpdate( 1,
[ ),
TabInfo { TabUpdate(
position: 0, [
name: "Tab #1", TabInfo {
active: false, position: 0,
panes_to_hide: 0, name: "Tab #1",
is_fullscreen_active: false, active: false,
is_sync_panes_active: false, panes_to_hide: 0,
are_floating_panes_visible: false, is_fullscreen_active: false,
other_focused_clients: [], is_sync_panes_active: false,
}, are_floating_panes_visible: false,
TabInfo { other_focused_clients: [],
position: 1, },
name: "", TabInfo {
active: true, position: 1,
panes_to_hide: 0, name: "new-tab-name",
is_fullscreen_active: false, active: true,
is_sync_panes_active: false, panes_to_hide: 0,
are_floating_panes_visible: false, is_fullscreen_active: false,
other_focused_clients: [], is_sync_panes_active: false,
}, are_floating_panes_visible: false,
], other_focused_clients: [],
), },
), ],
Update( ),
None, ),
Some( ],
1,
),
TabUpdate(
[
TabInfo {
position: 0,
name: "Tab #1",
active: false,
panes_to_hide: 0,
is_fullscreen_active: false,
is_sync_panes_active: false,
are_floating_panes_visible: false,
other_focused_clients: [],
},
TabInfo {
position: 1,
name: "new-tab-name",
active: true,
panes_to_hide: 0,
is_fullscreen_active: false,
is_sync_panes_active: false,
are_floating_panes_visible: false,
other_focused_clients: [],
},
],
),
), ),
Exit, Exit,
] ]

View file

@ -1,22 +1,30 @@
--- ---
source: zellij-server/src/./unit/screen_tests.rs source: zellij-server/src/./unit/screen_tests.rs
assertion_line: 2549 assertion_line: 2554
expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())" expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
--- ---
[ [
Update( Update(
None, [
Some( (
10, None,
), Some(
InputReceived, 10,
),
InputReceived,
),
],
), ),
Update( Update(
None, [
Some( (
10, None,
), Some(
InputReceived, 10,
),
InputReceived,
),
],
), ),
NewTab( NewTab(
None, None,
@ -58,176 +66,111 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
1, 1,
), ),
Update( Update(
None, [
Some( (
1, None,
), Some(
ModeUpdate( 1,
ModeInfo { ),
mode: Normal, ModeUpdate(
keybinds: [], ModeInfo {
style: Style { mode: Normal,
colors: Palette { keybinds: [],
source: Default, style: Style {
theme_hue: Dark, colors: Palette {
fg: EightBit( source: Default,
0, theme_hue: Dark,
), fg: EightBit(
bg: EightBit( 0,
0, ),
), bg: EightBit(
black: EightBit( 0,
0, ),
), black: EightBit(
red: EightBit( 0,
0, ),
), red: EightBit(
green: EightBit( 0,
0, ),
), green: EightBit(
yellow: EightBit( 0,
0, ),
), yellow: EightBit(
blue: EightBit( 0,
0, ),
), blue: EightBit(
magenta: EightBit( 0,
0, ),
), magenta: EightBit(
cyan: EightBit( 0,
0, ),
), cyan: EightBit(
white: EightBit( 0,
0, ),
), white: EightBit(
orange: EightBit( 0,
0, ),
), orange: EightBit(
gray: EightBit( 0,
0, ),
), gray: EightBit(
purple: EightBit( 0,
0, ),
), purple: EightBit(
gold: EightBit( 0,
0, ),
), gold: EightBit(
silver: EightBit( 0,
0, ),
), silver: EightBit(
pink: EightBit( 0,
0, ),
), pink: EightBit(
brown: EightBit( 0,
0, ),
brown: EightBit(
0,
),
},
rounded_corners: false,
},
capabilities: PluginCapabilities {
arrow_fonts: false,
},
session_name: Some(
"zellij-test",
), ),
}, },
rounded_corners: false,
},
capabilities: PluginCapabilities {
arrow_fonts: false,
},
session_name: Some(
"zellij-test",
), ),
}, ),
), ],
), ),
Update( Update(
None, [],
Some(
1,
),
ModeUpdate(
ModeInfo {
mode: Normal,
keybinds: [],
style: Style {
colors: Palette {
source: Default,
theme_hue: Dark,
fg: EightBit(
0,
),
bg: EightBit(
0,
),
black: EightBit(
0,
),
red: EightBit(
0,
),
green: EightBit(
0,
),
yellow: EightBit(
0,
),
blue: EightBit(
0,
),
magenta: EightBit(
0,
),
cyan: EightBit(
0,
),
white: EightBit(
0,
),
orange: EightBit(
0,
),
gray: EightBit(
0,
),
purple: EightBit(
0,
),
gold: EightBit(
0,
),
silver: EightBit(
0,
),
pink: EightBit(
0,
),
brown: EightBit(
0,
),
},
rounded_corners: false,
},
capabilities: PluginCapabilities {
arrow_fonts: false,
},
session_name: Some(
"zellij-test",
),
},
),
), ),
Update( Update(
None, [
Some( (
1, None,
), Some(
TabUpdate( 1,
[ ),
TabInfo { TabUpdate(
position: 0, [
name: "Tab #1", TabInfo {
active: true, position: 0,
panes_to_hide: 0, name: "Tab #1",
is_fullscreen_active: false, active: true,
is_sync_panes_active: false, panes_to_hide: 0,
are_floating_panes_visible: false, is_fullscreen_active: false,
other_focused_clients: [], is_sync_panes_active: false,
}, are_floating_panes_visible: false,
], other_focused_clients: [],
), },
],
),
),
],
), ),
NewTab( NewTab(
None, None,
@ -269,283 +212,237 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
1, 1,
), ),
Update( Update(
None, [],
Some( ),
1, Update(
), [
ModeUpdate( (
ModeInfo { None,
mode: Normal, Some(
keybinds: [], 1,
style: Style { ),
colors: Palette { ModeUpdate(
source: Default, ModeInfo {
theme_hue: Dark, mode: Normal,
fg: EightBit( keybinds: [],
0, style: Style {
), colors: Palette {
bg: EightBit( source: Default,
0, theme_hue: Dark,
), fg: EightBit(
black: EightBit( 0,
0, ),
), bg: EightBit(
red: EightBit( 0,
0, ),
), black: EightBit(
green: EightBit( 0,
0, ),
), red: EightBit(
yellow: EightBit( 0,
0, ),
), green: EightBit(
blue: EightBit( 0,
0, ),
), yellow: EightBit(
magenta: EightBit( 0,
0, ),
), blue: EightBit(
cyan: EightBit( 0,
0, ),
), magenta: EightBit(
white: EightBit( 0,
0, ),
), cyan: EightBit(
orange: EightBit( 0,
0, ),
), white: EightBit(
gray: EightBit( 0,
0, ),
), orange: EightBit(
purple: EightBit( 0,
0, ),
), gray: EightBit(
gold: EightBit( 0,
0, ),
), purple: EightBit(
silver: EightBit( 0,
0, ),
), gold: EightBit(
pink: EightBit( 0,
0, ),
), silver: EightBit(
brown: EightBit( 0,
0, ),
pink: EightBit(
0,
),
brown: EightBit(
0,
),
},
rounded_corners: false,
},
capabilities: PluginCapabilities {
arrow_fonts: false,
},
session_name: Some(
"zellij-test",
), ),
}, },
rounded_corners: false,
},
capabilities: PluginCapabilities {
arrow_fonts: false,
},
session_name: Some(
"zellij-test",
), ),
}, ),
), ],
), ),
Update( Update(
None, [],
Some( ),
1, Update(
), [
ModeUpdate( (
ModeInfo { None,
mode: Normal, Some(
keybinds: [], 1,
style: Style {
colors: Palette {
source: Default,
theme_hue: Dark,
fg: EightBit(
0,
),
bg: EightBit(
0,
),
black: EightBit(
0,
),
red: EightBit(
0,
),
green: EightBit(
0,
),
yellow: EightBit(
0,
),
blue: EightBit(
0,
),
magenta: EightBit(
0,
),
cyan: EightBit(
0,
),
white: EightBit(
0,
),
orange: EightBit(
0,
),
gray: EightBit(
0,
),
purple: EightBit(
0,
),
gold: EightBit(
0,
),
silver: EightBit(
0,
),
pink: EightBit(
0,
),
brown: EightBit(
0,
),
},
rounded_corners: false,
},
capabilities: PluginCapabilities {
arrow_fonts: false,
},
session_name: Some(
"zellij-test",
), ),
}, TabUpdate(
), [
TabInfo {
position: 0,
name: "Tab #1",
active: false,
panes_to_hide: 0,
is_fullscreen_active: false,
is_sync_panes_active: false,
are_floating_panes_visible: false,
other_focused_clients: [],
},
TabInfo {
position: 1,
name: "Tab #2",
active: true,
panes_to_hide: 0,
is_fullscreen_active: false,
is_sync_panes_active: false,
are_floating_panes_visible: false,
other_focused_clients: [],
},
],
),
),
],
), ),
Update( Update(
None, [
Some( (
1, None,
), Some(
TabUpdate( 1,
[ ),
TabInfo { TabUpdate(
position: 0, [
name: "Tab #1", TabInfo {
active: false, position: 0,
panes_to_hide: 0, name: "Tab #1",
is_fullscreen_active: false, active: false,
is_sync_panes_active: false, panes_to_hide: 0,
are_floating_panes_visible: false, is_fullscreen_active: false,
other_focused_clients: [], is_sync_panes_active: false,
}, are_floating_panes_visible: false,
TabInfo { other_focused_clients: [],
position: 1, },
name: "Tab #2", TabInfo {
active: true, position: 1,
panes_to_hide: 0, name: "",
is_fullscreen_active: false, active: true,
is_sync_panes_active: false, panes_to_hide: 0,
are_floating_panes_visible: false, is_fullscreen_active: false,
other_focused_clients: [], is_sync_panes_active: false,
}, are_floating_panes_visible: false,
], other_focused_clients: [],
), },
],
),
),
],
), ),
Update( Update(
None, [
Some( (
1, None,
), Some(
TabUpdate( 1,
[ ),
TabInfo { TabUpdate(
position: 0, [
name: "Tab #1", TabInfo {
active: false, position: 0,
panes_to_hide: 0, name: "Tab #1",
is_fullscreen_active: false, active: false,
is_sync_panes_active: false, panes_to_hide: 0,
are_floating_panes_visible: false, is_fullscreen_active: false,
other_focused_clients: [], is_sync_panes_active: false,
}, are_floating_panes_visible: false,
TabInfo { other_focused_clients: [],
position: 1, },
name: "", TabInfo {
active: true, position: 1,
panes_to_hide: 0, name: "new-tab-name",
is_fullscreen_active: false, active: true,
is_sync_panes_active: false, panes_to_hide: 0,
are_floating_panes_visible: false, is_fullscreen_active: false,
other_focused_clients: [], is_sync_panes_active: false,
}, are_floating_panes_visible: false,
], other_focused_clients: [],
), },
],
),
),
],
), ),
Update( Update(
None, [
Some( (
1, None,
), Some(
TabUpdate( 10,
[ ),
TabInfo { InputReceived,
position: 0, ),
name: "Tab #1", ],
active: false,
panes_to_hide: 0,
is_fullscreen_active: false,
is_sync_panes_active: false,
are_floating_panes_visible: false,
other_focused_clients: [],
},
TabInfo {
position: 1,
name: "new-tab-name",
active: true,
panes_to_hide: 0,
is_fullscreen_active: false,
is_sync_panes_active: false,
are_floating_panes_visible: false,
other_focused_clients: [],
},
],
),
), ),
Update( Update(
None, [
Some( (
10, None,
), Some(
InputReceived, 1,
), ),
Update( TabUpdate(
None, [
Some( TabInfo {
1, position: 0,
), name: "Tab #1",
TabUpdate( active: false,
[ panes_to_hide: 0,
TabInfo { is_fullscreen_active: false,
position: 0, is_sync_panes_active: false,
name: "Tab #1", are_floating_panes_visible: false,
active: false, other_focused_clients: [],
panes_to_hide: 0, },
is_fullscreen_active: false, TabInfo {
is_sync_panes_active: false, position: 1,
are_floating_panes_visible: false, name: "Tab #2",
other_focused_clients: [], active: true,
}, panes_to_hide: 0,
TabInfo { is_fullscreen_active: false,
position: 1, is_sync_panes_active: false,
name: "Tab #2", are_floating_panes_visible: false,
active: true, other_focused_clients: [],
panes_to_hide: 0, },
is_fullscreen_active: false, ],
is_sync_panes_active: false, ),
are_floating_panes_visible: false, ),
other_focused_clients: [], ],
},
],
),
), ),
Exit, Exit,
] ]