diff options
| author | Aram Drevekenin <aram@poor.dev> | 2026-03-26 12:49:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-26 12:49:05 +0100 |
| commit | 12ee607532d8894b7dff1f29143f073783bd4445 (patch) | |
| tree | eb1c57037850be4a9cde4855680dac27cce55c5e /zellij-utils/src | |
| parent | fix: do not reset layout selection in layout manager (#4919) (diff) | |
| download | sl0ppij-12ee607532d8894b7dff1f29143f073783bd4445.tar.gz sl0ppij-12ee607532d8894b7dff1f29143f073783bd4445.tar.xz sl0ppij-12ee607532d8894b7dff1f29143f073783bd4445.zip | |
fix: performance regression when switching tabs (#4918)
* remove pane render report
* only collect pane contents if pane should render
* add logs
* conditional keybinding serialization
* remove logs
* rustfmt
* fix tests
* tests
* rustfmt
Diffstat (limited to 'zellij-utils/src')
| -rw-r--r-- | zellij-utils/src/data.rs | 4 | ||||
| -rw-r--r-- | zellij-utils/src/errors.rs | 2 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/event.proto | 6 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/event.rs | 62 |
4 files changed, 74 insertions, 0 deletions
diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs index badf106b..9e756fb1 100644 --- a/zellij-utils/src/data.rs +++ b/zellij-utils/src/data.rs @@ -1020,6 +1020,10 @@ pub enum Event { matched_string: String, context: BTreeMap<String, String>, }, + /// Initial keybindings sent once on plugin load and on reconfiguration. + /// Plugins that subscribe to this event signal they cache keybindings + /// and can handle lightweight ModeUpdate events without keybindings. + InitialKeybinds(KeybindsVec), } #[derive(Debug, Clone, PartialEq, Eq, EnumDiscriminants, Display, Serialize, Deserialize)] diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs index 51e47bd0..324fae33 100644 --- a/zellij-utils/src/errors.rs +++ b/zellij-utils/src/errors.rs @@ -449,6 +449,8 @@ pub enum ScreenContext { NextSwapLayoutWithTabId, MoveTabWithTabId, PluginSubscribedToAnsiPaneContents, + UpdateBackgroundPluginSubscriptions, + BroadcastModeUpdate, } /// Stack call representations corresponding to the different types of [`PtyInstruction`]s. diff --git a/zellij-utils/src/plugin_api/event.proto b/zellij-utils/src/plugin_api/event.proto index 1ecfa484..ce9eb8ff 100644 --- a/zellij-utils/src/plugin_api/event.proto +++ b/zellij-utils/src/plugin_api/event.proto @@ -66,6 +66,7 @@ enum EventType { PluginConfigurationChanged = 41; HighlightClicked = 42; PaneRenderReportWithAnsi = 43; + InitialKeybinds = 44; } message EventNameList { @@ -111,6 +112,7 @@ message Event { PluginConfigurationChangedPayload plugin_configuration_changed_payload = 35; HighlightClickedPayload highlight_clicked_payload = 36; PaneRenderReportPayload pane_render_report_with_ansi_payload = 37; + InitialKeybindsPayload initial_keybinds_payload = 38; } } @@ -528,3 +530,7 @@ message HighlightClickedPayload { repeated ContextItem context = 4; } +message InitialKeybindsPayload { + repeated InputModeKeybinds keybinds = 1; +} + diff --git a/zellij-utils/src/plugin_api/event.rs b/zellij-utils/src/plugin_api/event.rs index bb5b43d3..93b28365 100644 --- a/zellij-utils/src/plugin_api/event.rs +++ b/zellij-utils/src/plugin_api/event.rs @@ -528,6 +528,34 @@ impl TryFrom<ProtobufEvent> for Event { }, _ => Err("Malformed payload for HighlightClicked Event"), }, + Some(ProtobufEventType::InitialKeybinds) => match protobuf_event.payload { + Some(ProtobufEventPayload::InitialKeybindsPayload(p)) => { + let keybinds = p + .keybinds + .into_iter() + .filter_map(|imk| { + let mode: InputMode = + ProtobufInputMode::from_i32(imk.mode)?.try_into().ok()?; + let key_binds: Vec<(KeyWithModifier, Vec<Action>)> = imk + .key_bind + .into_iter() + .filter_map(|kb| { + let key: KeyWithModifier = kb.key?.try_into().ok()?; + let actions: Vec<Action> = kb + .action + .into_iter() + .filter_map(|a| a.try_into().ok()) + .collect(); + Some((key, actions)) + }) + .collect(); + Some((mode, key_binds)) + }) + .collect(); + Ok(Event::InitialKeybinds(keybinds)) + }, + _ => Err("Malformed payload for InitialKeybinds Event"), + }, None => Err("Unknown Protobuf Event"), } } @@ -1044,6 +1072,38 @@ impl TryFrom<Event> for ProtobufEvent { }, )), }), + Event::InitialKeybinds(keybinds) => { + let mut protobuf_keybinds: Vec<ProtobufInputModeKeybinds> = vec![]; + for (input_mode, input_mode_keybinds) in keybinds { + let mode: ProtobufInputMode = input_mode.try_into()?; + let mut key_binds: Vec<ProtobufKeyBind> = vec![]; + for (key, actions) in input_mode_keybinds { + let protobuf_key: ProtobufKey = key.try_into()?; + let mut protobuf_actions: Vec<ProtobufAction> = vec![]; + for action in actions { + if let Ok(protobuf_action) = action.try_into() { + protobuf_actions.push(protobuf_action); + } + } + key_binds.push(ProtobufKeyBind { + key: Some(protobuf_key), + action: protobuf_actions, + }); + } + protobuf_keybinds.push(ProtobufInputModeKeybinds { + mode: mode as i32, + key_bind: key_binds, + }); + } + Ok(ProtobufEvent { + name: ProtobufEventType::InitialKeybinds as i32, + payload: Some(event::Payload::InitialKeybindsPayload( + InitialKeybindsPayload { + keybinds: protobuf_keybinds, + }, + )), + }) + }, } } } @@ -1958,6 +2018,7 @@ impl TryFrom<ProtobufEventType> for EventType { ProtobufEventType::AvailableLayoutInfo => EventType::AvailableLayoutInfo, ProtobufEventType::PluginConfigurationChanged => EventType::PluginConfigurationChanged, ProtobufEventType::HighlightClicked => EventType::HighlightClicked, + ProtobufEventType::InitialKeybinds => EventType::InitialKeybinds, }) } } @@ -2009,6 +2070,7 @@ impl TryFrom<EventType> for ProtobufEventType { EventType::AvailableLayoutInfo => ProtobufEventType::AvailableLayoutInfo, EventType::PluginConfigurationChanged => ProtobufEventType::PluginConfigurationChanged, EventType::HighlightClicked => ProtobufEventType::HighlightClicked, + EventType::InitialKeybinds => ProtobufEventType::InitialKeybinds, }) } } |
