Skip to content

Commit

Permalink
fix(wm): valid directions all require count > 1
Browse files Browse the repository at this point in the history
This is a mixture of refactoring and a fix, updating the
Direction::is_valid_direction trait impl for Default layout to return
early with false if the count is < 2.

fix #851
  • Loading branch information
LGUG2Z committed May 30, 2024
1 parent fd97c72 commit e8f6a66
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions komorebi-core/src/direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,21 @@ impl Direction for DefaultLayout {
idx: usize,
count: usize,
) -> bool {
if count < 2 {
return false;
}

match op_direction {
OperationDirection::Up => match self {
Self::BSP => count > 2 && idx != 0 && idx != 1,
Self::BSP => idx != 0 && idx != 1,
Self::Columns => false,
Self::Rows | Self::HorizontalStack => idx != 0,
Self::VerticalStack | Self::RightMainVerticalStack => idx != 0 && idx != 1,
Self::UltrawideVerticalStack => idx > 2,
Self::Grid => !is_grid_edge(op_direction, idx, count),
},
OperationDirection::Down => match self {
Self::BSP => count > 2 && idx != count - 1 && idx % 2 != 0,
Self::BSP => idx != count - 1 && idx % 2 != 0,
Self::Columns => false,
Self::Rows => idx != count - 1,
Self::VerticalStack | Self::RightMainVerticalStack => idx != 0 && idx != count - 1,
Expand All @@ -109,23 +113,22 @@ impl Direction for DefaultLayout {
Self::Grid => !is_grid_edge(op_direction, idx, count),
},
OperationDirection::Left => match self {
Self::BSP => count > 1 && idx != 0,
Self::BSP => idx != 0,
Self::Columns | Self::VerticalStack => idx != 0,
Self::RightMainVerticalStack => idx == 0,
Self::Rows => false,
Self::HorizontalStack => idx != 0 && idx != 1,
Self::UltrawideVerticalStack => count > 1 && idx != 1,
Self::UltrawideVerticalStack => idx != 1,
Self::Grid => !is_grid_edge(op_direction, idx, count),
},
OperationDirection::Right => match self {
Self::BSP => count > 1 && idx % 2 == 0 && idx != count - 1,
Self::BSP => idx % 2 == 0 && idx != count - 1,
Self::Columns => idx != count - 1,
Self::Rows => false,
Self::VerticalStack => idx == 0,
Self::RightMainVerticalStack => idx != 0,
Self::HorizontalStack => idx != 0 && idx != count - 1,
Self::UltrawideVerticalStack => match count {
0 | 1 => false,
2 => idx != 0,
_ => idx < 2,
},
Expand Down

0 comments on commit e8f6a66

Please sign in to comment.