Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement resize code #1990

Merged
merged 34 commits into from
Dec 8, 2022
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6cf47ec
server/floating_panes: Start removing `unwrap`s
har7an Nov 24, 2022
2b4ac5e
server/panes: Remove more `unwrap`s
har7an Nov 30, 2022
4234c29
utils/data: Unify `Direction` type
har7an Nov 30, 2022
fa54dc3
server: Implement new resize handling
har7an Nov 30, 2022
40eaf58
utils/layout: Add conversion for SplitDirection
har7an Dec 1, 2022
eba5e8a
utils/data: Add impl for `Direction`
har7an Dec 1, 2022
cd13147
server/panes: Rework tiled pane resizing
har7an Dec 1, 2022
233f599
server/panes/tiled_panes: Add debug assertion
har7an Dec 3, 2022
e06d7d0
server/panes/tiled/grid: Fix resize bug
har7an Dec 3, 2022
3e0306c
utils/data: Add `invert` for `Resize`
har7an Dec 4, 2022
c674445
utils/data: Add member to `ResizeStrategy`
har7an Dec 4, 2022
9b4ebb0
server/screen: Handle new attribute
har7an Dec 4, 2022
207e5b5
server/panes/resizer: Return `anyhow::Error`
har7an Dec 4, 2022
fa87b2b
server/panes/tiled: Implement resize increase/decrease
har7an Dec 4, 2022
21ca240
server/pane/tiled/grid: Don't return early
har7an Dec 5, 2022
6164113
server/pane/tiled/grid: Fix resize bug
har7an Dec 5, 2022
7833ade
server/panes/tiled/grid: Cleanup code
har7an Dec 5, 2022
66163d2
server/panes/float/grid: Invert resize
har7an Dec 5, 2022
3670287
plugins/status-bar: Add hints for new resize
har7an Dec 5, 2022
7e96a6a
server: Use new resize method
har7an Dec 5, 2022
a757838
server: Fix tests
har7an Dec 5, 2022
809acf6
apply rustfmt
har7an Dec 5, 2022
44eeafe
utils: Apply rustfmt
har7an Dec 5, 2022
347e655
server/panes/floating: Fix resize increase
har7an Dec 7, 2022
81181a2
server/panes/tiled: Use correct resize increments
har7an Dec 7, 2022
756ab2e
server/panes/tiled: Fix resize checks
har7an Dec 7, 2022
e92213e
utils/assets/config: Update default config
har7an Dec 7, 2022
ff8c165
server/panes/tiled: Fix resize check
har7an Dec 7, 2022
6bb3fd7
server/panes/tiled: Use shortener for `Direction`
har7an Dec 7, 2022
d8bc8ed
server/panes/tiled: Restore resize behavior
har7an Dec 7, 2022
a7e9d20
server/panes/floating: Fix resize increment
har7an Dec 7, 2022
008ef2f
utils/data: Fix doctest
har7an Dec 7, 2022
54336ae
utils: Fix test snapshots
har7an Dec 7, 2022
cb08b2c
changelog: Add PR #1990
har7an Dec 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
server/panes/tiled/grid: Cleanup code
and remove log statements and unused functions.
  • Loading branch information
har7an committed Dec 7, 2022
commit 7833ade1cbe48ca5c74706c980a9c33171541daa
36 changes: 1 addition & 35 deletions zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ impl<'a> TiledPaneGrid<'a> {
.collect()
};

log::info!("neighbor terminals before: {neighbor_terminals:?}");

// Only resize those neighbors that are aligned and between pane borders
let (some_direction, other_direction) = match direction {
Direction::Left | Direction::Right => (Direction::Up, Direction::Down),
Expand Down Expand Up @@ -232,9 +230,6 @@ impl<'a> TiledPaneGrid<'a> {
}
});

log::info!("neighbor terminals after: {neighbor_terminals:?}");
log::info!("terminal borders: '{some_borders:?}', '{other_borders:?}'");

// Perform the resize
let change_by = match direction {
Direction::Left | Direction::Right => change_by.0,
Expand Down Expand Up @@ -280,7 +275,7 @@ impl<'a> TiledPaneGrid<'a> {
} else {
return Err(anyhow!(
"Don't know how to perform resize operation: '{strategy}'"
));
)).with_context(err_context);
}

// Update grid
Expand Down Expand Up @@ -583,8 +578,6 @@ impl<'a> TiledPaneGrid<'a> {
})
.with_context(err_context)?;

log::info!("Panes aligned with {id:?}: {:?}", aligned_panes.iter().map(|p| p.pid()).collect::<Vec<_>>());

use Direction::Down as D;
use Direction::Left as L;
use Direction::Right as R;
Expand All @@ -611,8 +604,6 @@ impl<'a> TiledPaneGrid<'a> {
}
}

log::info!("Candidate panes: {:?}", result.iter().map(|p| p.pid()).collect::<Vec<_>>());

let mut resize_border = match direction {
&L => 0,
&D => self.viewport.y + self.viewport.rows,
Expand Down Expand Up @@ -649,8 +640,6 @@ impl<'a> TiledPaneGrid<'a> {
&R => (pane.x() + pane.cols()) <= resize_border,
});

log::info!("aligned panes: {:?}", result.iter().map(|p| p.pid()).collect::<Vec<_>>());

let resize_border = if result.is_empty() {
match direction {
&L => pane_to_check.x(),
Expand All @@ -666,29 +655,6 @@ impl<'a> TiledPaneGrid<'a> {
Ok((resize_border, pane_ids))
}

// Returns true if none of the `pane_ids` has a `Fixed` dimension
fn ids_are_flexible(&self, direction: SplitDirection, pane_ids: Vec<PaneId>) -> Result<bool> {
let err_context =
|| format!("failed to determine if panes {pane_ids:?} are flexible in {direction:?}");

let panes = self.panes.borrow();
for id in pane_ids.iter() {
let pane_to_check = panes
.get(&id)
.with_context(|| no_pane_id(&id))
.with_context(err_context)?;
let geom = pane_to_check.current_geom();
let dimension = match direction {
SplitDirection::Vertical => geom.rows,
SplitDirection::Horizontal => geom.cols,
};
if dimension.is_fixed() {
return Ok(false);
}
}
Ok(true)
}

fn pane_is_between_vertical_borders(
&self,
id: &PaneId,
Expand Down