diff options
| author | Aram Drevekenin <aram@poor.dev> | 2023-06-15 17:07:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-15 17:07:40 +0200 |
| commit | bcbd940bf94cd76751af9b5fad64b716ce2cd3e6 (patch) | |
| tree | 3bfed3792edd57f074c4aed9093c90bc6ed215fe /zellij-server/src/unit | |
| parent | docs(changelog): relative plugin urls (diff) | |
| download | sl0ppij-bcbd940bf94cd76751af9b5fad64b716ce2cd3e6.tar.gz sl0ppij-bcbd940bf94cd76751af9b5fad64b716ce2cd3e6.tar.xz sl0ppij-bcbd940bf94cd76751af9b5fad64b716ce2cd3e6.zip | |
feat(plugins): plugin pane state events (#2545)
* feat(plugins): report pane state to plugins
* refactor(plugins): rename some stuff
* tests(plugins): adjust for new behavior
* style(fmt): rustfmt
Diffstat (limited to 'zellij-server/src/unit')
3 files changed, 41 insertions, 906 deletions
diff --git a/zellij-server/src/unit/screen_tests.rs b/zellij-server/src/unit/screen_tests.rs index 51dfbfd3..1040062b 100644 --- a/zellij-server/src/unit/screen_tests.rs +++ b/zellij-server/src/unit/screen_tests.rs @@ -10,7 +10,7 @@ use crate::{ use insta::assert_snapshot; use std::path::PathBuf; use zellij_utils::cli::CliAction; -use zellij_utils::data::Resize; +use zellij_utils::data::{Event, Resize}; use zellij_utils::errors::{prelude::*, ErrorContext}; use zellij_utils::input::actions::Action; use zellij_utils::input::command::{RunCommand, TerminalAction}; @@ -2431,10 +2431,22 @@ pub fn send_cli_rename_tab() { send_cli_action_to_server(&session_metadata, rename_tab, client_id); std::thread::sleep(std::time::Duration::from_millis(100)); mock_screen.teardown(vec![plugin_thread, screen_thread]); - assert_snapshot!(format!( - "{:#?}", - *received_plugin_instructions.lock().unwrap() - )) + let plugin_rename_tab_instruction = received_plugin_instructions + .lock() + .unwrap() + .iter() + .find(|instruction| match instruction { + PluginInstruction::Update(updates) => updates + .iter() + .find(|u| match u { + (_, _, Event::TabUpdate(..)) => true, + _ => false, + }) + .is_some(), + _ => false, + }) + .cloned(); + assert_snapshot!(format!("{:#?}", plugin_rename_tab_instruction)) } #[test] @@ -2469,10 +2481,22 @@ pub fn send_cli_undo_rename_tab() { send_cli_action_to_server(&session_metadata, undo_rename_tab, client_id); std::thread::sleep(std::time::Duration::from_millis(100)); mock_screen.teardown(vec![plugin_thread, screen_thread]); - assert_snapshot!(format!( - "{:#?}", - *received_plugin_instructions.lock().unwrap() - )) + let plugin_undo_rename_tab_instruction = received_plugin_instructions + .lock() + .unwrap() + .iter() + .find(|instruction| match instruction { + PluginInstruction::Update(updates) => updates + .iter() + .find(|u| match u { + (_, _, Event::TabUpdate(..)) => true, + _ => false, + }) + .is_some(), + _ => false, + }) + .cloned(); + assert_snapshot!(format!("{:#?}", plugin_undo_rename_tab_instruction)) } #[test] diff --git a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_rename_tab.snap b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_rename_tab.snap index f5e86b28..0538dbcd 100644 --- a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_rename_tab.snap +++ b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_rename_tab.snap @@ -1,164 +1,9 @@ --- source: zellij-server/src/./unit/screen_tests.rs -assertion_line: 2632 -expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())" +assertion_line: 2448 +expression: "format!(\"{:#?}\", plugin_rename_tab_instruction)" --- -[ - Update( - [ - ( - None, - Some( - 10, - ), - InputReceived, - ), - ], - ), - Update( - [ - ( - None, - Some( - 10, - ), - InputReceived, - ), - ], - ), - NewTab( - None, - None, - Some( - TiledPaneLayout { - children_split_direction: Horizontal, - name: None, - children: [ - TiledPaneLayout { - children_split_direction: Horizontal, - name: None, - children: [], - split_size: None, - run: None, - borderless: false, - focus: None, - external_children_index: None, - children_are_stacked: false, - is_expanded_in_stack: false, - exclude_from_sync: None, - }, - TiledPaneLayout { - children_split_direction: Horizontal, - name: None, - children: [], - split_size: None, - run: None, - borderless: false, - focus: None, - external_children_index: None, - children_are_stacked: false, - is_expanded_in_stack: false, - exclude_from_sync: None, - }, - ], - split_size: None, - run: None, - borderless: false, - focus: None, - external_children_index: None, - children_are_stacked: false, - is_expanded_in_stack: false, - exclude_from_sync: None, - }, - ), - [], - 0, - 1, - ), - 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, - hide_session_name: false, - }, - capabilities: PluginCapabilities { - arrow_fonts: false, - }, - session_name: Some( - "zellij-test", - ), - }, - ), - ), - ], - ), - Update( - [], - ), +Some( Update( [ ( @@ -187,267 +32,4 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())" ), ], ), - NewTab( - None, - None, - Some( - TiledPaneLayout { - children_split_direction: Vertical, - name: None, - children: [ - TiledPaneLayout { - children_split_direction: Horizontal, - name: None, - children: [], - split_size: None, - run: None, - borderless: false, - focus: None, - external_children_index: None, - children_are_stacked: false, - is_expanded_in_stack: false, - exclude_from_sync: None, - }, - TiledPaneLayout { - children_split_direction: Horizontal, - name: None, - children: [], - split_size: None, - run: None, - borderless: false, - focus: None, - external_children_index: None, - children_are_stacked: false, - is_expanded_in_stack: false, - exclude_from_sync: None, - }, - ], - split_size: None, - run: None, - borderless: false, - focus: None, - external_children_index: None, - children_are_stacked: false, - is_expanded_in_stack: false, - exclude_from_sync: None, - }, - ), - [], - 1, - 1, - ), - 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, - hide_session_name: false, - }, - capabilities: PluginCapabilities { - arrow_fonts: false, - }, - session_name: Some( - "zellij-test", - ), - }, - ), - ), - ], - ), - Update( - [], - ), - 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: [], - active_swap_layout_name: Some( - "BASE", - ), - is_swap_layout_dirty: false, - }, - 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: [], - active_swap_layout_name: Some( - "BASE", - ), - is_swap_layout_dirty: false, - }, - ], - ), - ), - ], - ), - 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: [], - active_swap_layout_name: Some( - "BASE", - ), - is_swap_layout_dirty: false, - }, - TabInfo { - position: 1, - name: "", - active: true, - panes_to_hide: 0, - is_fullscreen_active: false, - is_sync_panes_active: false, - are_floating_panes_visible: false, - other_focused_clients: [], - active_swap_layout_name: Some( - "BASE", - ), - is_swap_layout_dirty: false, - }, - ], - ), - ), - ], - ), - 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: [], - active_swap_layout_name: Some( - "BASE", - ), - is_swap_layout_dirty: false, - }, - 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: [], - active_swap_layout_name: Some( - "BASE", - ), - is_swap_layout_dirty: false, - }, - ], - ), - ), - ], - ), - Exit, -] +) diff --git a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_undo_rename_tab.snap b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_undo_rename_tab.snap index bae48188..d19474f2 100644 --- a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_undo_rename_tab.snap +++ b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_undo_rename_tab.snap @@ -1,164 +1,9 @@ --- source: zellij-server/src/./unit/screen_tests.rs -assertion_line: 2675 -expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())" +assertion_line: 2486 +expression: "format!(\"{:#?}\", plugin_undo_rename_tab_instruction)" --- -[ - Update( - [ - ( - None, - Some( - 10, - ), - InputReceived, - ), - ], - ), - Update( - [ - ( - None, - Some( - 10, - ), - InputReceived, - ), - ], - ), - NewTab( - None, - None, - Some( - TiledPaneLayout { - children_split_direction: Horizontal, - name: None, - children: [ - TiledPaneLayout { - children_split_direction: Horizontal, - name: None, - children: [], - split_size: None, - run: None, - borderless: false, - focus: None, - external_children_index: None, - children_are_stacked: false, - is_expanded_in_stack: false, - exclude_from_sync: None, - }, - TiledPaneLayout { - children_split_direction: Horizontal, - name: None, - children: [], - split_size: None, - run: None, - borderless: false, - focus: None, - external_children_index: None, - children_are_stacked: false, - is_expanded_in_stack: false, - exclude_from_sync: None, - }, - ], - split_size: None, - run: None, - borderless: false, - focus: None, - external_children_index: None, - children_are_stacked: false, - is_expanded_in_stack: false, - exclude_from_sync: None, - }, - ), - [], - 0, - 1, - ), - 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, - hide_session_name: false, - }, - capabilities: PluginCapabilities { - arrow_fonts: false, - }, - session_name: Some( - "zellij-test", - ), - }, - ), - ), - ], - ), - Update( - [], - ), +Some( Update( [ ( @@ -187,320 +32,4 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())" ), ], ), - NewTab( - None, - None, - Some( - TiledPaneLayout { - children_split_direction: Vertical, - name: None, - children: [ - TiledPaneLayout { - children_split_direction: Horizontal, - name: None, - children: [], - split_size: None, - run: None, - borderless: false, - focus: None, - external_children_index: None, - children_are_stacked: false, - is_expanded_in_stack: false, - exclude_from_sync: None, - }, - TiledPaneLayout { - children_split_direction: Horizontal, - name: None, - children: [], - split_size: None, - run: None, - borderless: false, - focus: None, - external_children_index: None, - children_are_stacked: false, - is_expanded_in_stack: false, - exclude_from_sync: None, - }, - ], - split_size: None, - run: None, - borderless: false, - focus: None, - external_children_index: None, - children_are_stacked: false, - is_expanded_in_stack: false, - exclude_from_sync: None, - }, - ), - [], - 1, - 1, - ), - 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, - hide_session_name: false, - }, - capabilities: PluginCapabilities { - arrow_fonts: false, - }, - session_name: Some( - "zellij-test", - ), - }, - ), - ), - ], - ), - Update( - [], - ), - 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: [], - active_swap_layout_name: Some( - "BASE", - ), - is_swap_layout_dirty: false, - }, - 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: [], - active_swap_layout_name: Some( - "BASE", - ), - is_swap_layout_dirty: false, - }, - ], - ), - ), - ], - ), - 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: [], - active_swap_layout_name: Some( - "BASE", - ), - is_swap_layout_dirty: false, - }, - TabInfo { - position: 1, - name: "", - active: true, - panes_to_hide: 0, - is_fullscreen_active: false, - is_sync_panes_active: false, - are_floating_panes_visible: false, - other_focused_clients: [], - active_swap_layout_name: Some( - "BASE", - ), - is_swap_layout_dirty: false, - }, - ], - ), - ), - ], - ), - 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: [], - active_swap_layout_name: Some( - "BASE", - ), - is_swap_layout_dirty: false, - }, - 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: [], - active_swap_layout_name: Some( - "BASE", - ), - is_swap_layout_dirty: false, - }, - ], - ), - ), - ], - ), - Update( - [ - ( - None, - Some( - 10, - ), - InputReceived, - ), - ], - ), - 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: [], - active_swap_layout_name: Some( - "BASE", - ), - is_swap_layout_dirty: false, - }, - 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: [], - active_swap_layout_name: Some( - "BASE", - ), - is_swap_layout_dirty: false, - }, - ], - ), - ), - ], - ), - Exit, -] +) |
