diff options
| author | Aram Drevekenin <aram@poor.dev> | 2026-01-15 14:10:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-15 14:10:59 +0100 |
| commit | 005769cfa58b65cc6b2d6ce273ad367bf802bfb0 (patch) | |
| tree | 1912882005cc78bd27d53414ab672b6a13ecd4c8 /zellij-utils/src/ipc/protobuf_conversion.rs | |
| parent | fix: properly quit welcome screen when switching sessions (#4605) (diff) | |
| download | sl0ppij-005769cfa58b65cc6b2d6ce273ad367bf802bfb0.tar.gz sl0ppij-005769cfa58b65cc6b2d6ce273ad367bf802bfb0.tar.xz sl0ppij-005769cfa58b65cc6b2d6ce273ad367bf802bfb0.zip | |
Fix: allow 0% coordinate specification for floating panes (#4609)
* fix: allow 0% when specifying x/y coordinates but not when specifying width/height
* rustfmt
* add pr
Diffstat (limited to 'zellij-utils/src/ipc/protobuf_conversion.rs')
| -rw-r--r-- | zellij-utils/src/ipc/protobuf_conversion.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/zellij-utils/src/ipc/protobuf_conversion.rs b/zellij-utils/src/ipc/protobuf_conversion.rs index 4ade64b6..7539fa15 100644 --- a/zellij-utils/src/ipc/protobuf_conversion.rs +++ b/zellij-utils/src/ipc/protobuf_conversion.rs @@ -2443,6 +2443,43 @@ impl TryFrom<crate::client_server_contract::client_server_contract::FloatingCoor } } +// FloatingCoordinate conversion - PercentOrFixed to FloatingCoordinate +impl From<crate::input::layout::PercentOrFixed> + for crate::client_server_contract::client_server_contract::FloatingCoordinate +{ + fn from(size: crate::input::layout::PercentOrFixed) -> Self { + match size { + crate::input::layout::PercentOrFixed::Percent(p) => Self { + coordinate_type: Some(crate::client_server_contract::client_server_contract::floating_coordinate::CoordinateType::Percent(p as f32)), + }, + crate::input::layout::PercentOrFixed::Fixed(f) => Self { + coordinate_type: Some(crate::client_server_contract::client_server_contract::floating_coordinate::CoordinateType::Fixed(f as u32)), + }, + } + } +} + +// Reverse FloatingCoordinate conversion for PercentOrFixed +impl TryFrom<crate::client_server_contract::client_server_contract::FloatingCoordinate> + for crate::input::layout::PercentOrFixed +{ + type Error = anyhow::Error; + fn try_from( + coord: crate::client_server_contract::client_server_contract::FloatingCoordinate, + ) -> Result<Self> { + use crate::client_server_contract::client_server_contract::floating_coordinate::CoordinateType; + match coord + .coordinate_type + .ok_or_else(|| anyhow!("FloatingCoordinate missing coordinate_type"))? + { + CoordinateType::Percent(p) => { + Ok(crate::input::layout::PercentOrFixed::Percent(p as usize)) + }, + CoordinateType::Fixed(f) => Ok(crate::input::layout::PercentOrFixed::Fixed(f as usize)), + } + } +} + // FloatingPaneCoordinates conversion impl From<crate::data::FloatingPaneCoordinates> for crate::client_server_contract::client_server_contract::FloatingPaneCoordinates |
