Skip to content

Commit

Permalink
api: correctly open relatively positioned windows
Browse files Browse the repository at this point in the history
  • Loading branch information
noib3 committed Sep 30, 2023
1 parent e395024 commit 11fa6b2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions crates/oxi-api/src/types/window_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use oxi_types::{
use serde::Deserialize;

use super::{WindowAnchor, WindowBorder, WindowRelativeTo, WindowStyle};
use crate::Window;

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
Expand Down Expand Up @@ -56,6 +57,10 @@ pub struct WindowConfig {
/// Window width in character cells. Minimum of 1.
pub width: Option<u32>,

/// For relative positioned windows, the [`Window`] that the window is
/// positioned relative to.
pub win: Option<Window>,

/// Stacking order. Windows with higher `zindex` go in front of windows
/// with lower indices.
pub zindex: Option<u32>,
Expand Down Expand Up @@ -155,6 +160,9 @@ impl WindowConfigBuilder {
/// What the window is positioned relative to.
#[inline]
pub fn relative(&mut self, relative: WindowRelativeTo) -> &mut Self {
if let WindowRelativeTo::Window(win) = &relative {
self.0.win = Some(win.clone());
}
self.0.relative = Some(relative);
self
}
Expand Down Expand Up @@ -280,11 +288,6 @@ pub(crate) struct KeyDict_float_config {

impl From<&WindowConfig> for KeyDict_float_config {
fn from(config: &WindowConfig) -> Self {
let win = match &config.relative {
Some(WindowRelativeTo::Window(win)) => win.0.into(),
_ => Object::nil(),
};

let bufpos = match config.bufpos {
Some((line, column)) => {
Array::from_iter([line as Integer, column as Integer]).into()
Expand All @@ -295,7 +298,7 @@ impl From<&WindowConfig> for KeyDict_float_config {
Self {
col: config.col.into(),
row: config.row.into(),
win,
win: config.win.as_ref().into(),
style: config.style.into(),
#[cfg(any(feature = "neovim-0-9", feature = "neovim-nightly"))]
title: config.title.as_ref().into(),
Expand Down

0 comments on commit 11fa6b2

Please sign in to comment.