From 46c9802f6fd7cf37dab6c775554a9b7b9aa39bfd Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Tue, 16 Mar 2021 16:54:07 +0100 Subject: [PATCH] Performance: only render panes that should be updated (#234) * fix(performance): bring back should_render * style(fmt): rustfmt --- src/client/panes/terminal_pane.rs | 20 ++------------------ src/client/tab.rs | 4 ---- src/tests/fakes.rs | 11 +++++++++-- src/tests/integration/expansion_boundary.rs | 11 +++++++++-- src/tests/integration/resize_down.rs | 16 +++++++++++++++- src/tests/integration/resize_left.rs | 15 ++++++++++++++- src/tests/integration/resize_right.rs | 15 ++++++++++++++- src/tests/integration/resize_up.rs | 15 ++++++++++++++- src/tests/utils.rs | 1 + 9 files changed, 78 insertions(+), 30 deletions(-) diff --git a/src/client/panes/terminal_pane.rs b/src/client/panes/terminal_pane.rs index 4a0321af..9fa70d11 100644 --- a/src/client/panes/terminal_pane.rs +++ b/src/client/panes/terminal_pane.rs @@ -70,13 +70,11 @@ impl Pane for TerminalPane { fn reset_size_and_position_override(&mut self) { self.position_and_size_override = None; self.reflow_lines(); - self.mark_for_rerender(); } fn change_pos_and_size(&mut self, position_and_size: &PositionAndSize) { self.position_and_size.columns = position_and_size.columns; self.position_and_size.rows = position_and_size.rows; self.reflow_lines(); - self.mark_for_rerender(); } fn override_size_and_position(&mut self, x: usize, y: usize, size: &PositionAndSize) { let position_and_size_override = PositionAndSize { @@ -87,7 +85,6 @@ impl Pane for TerminalPane { }; self.position_and_size_override = Some(position_and_size_override); self.reflow_lines(); - self.mark_for_rerender(); } fn handle_event(&mut self, event: VteEvent) { match event { @@ -191,12 +188,7 @@ impl Pane for TerminalPane { self.max_height } fn render(&mut self) -> Option { - // if self.should_render { - if true { - // while checking should_render rather than rendering each pane every time - // is more performant, it causes some problems when the pane to the left should be - // rendered and has wide characters (eg. Chinese characters or emoji) - // as a (hopefully) temporary hack, we render all panes until we find a better solution + if self.should_render || cfg!(test) { let mut vte_output = String::new(); let buffer_lines = &self.read_buffer_as_lines(); let display_cols = self.get_columns(); @@ -238,7 +230,7 @@ impl Pane for TerminalPane { } character_styles.clear(); } - self.mark_for_rerender(); + self.should_render = false; Some(vte_output) } else { None @@ -251,45 +243,37 @@ impl Pane for TerminalPane { self.position_and_size.y += count; self.position_and_size.rows -= count; self.reflow_lines(); - self.mark_for_rerender(); } fn increase_height_down(&mut self, count: usize) { self.position_and_size.rows += count; self.reflow_lines(); - self.mark_for_rerender(); } fn increase_height_up(&mut self, count: usize) { self.position_and_size.y -= count; self.position_and_size.rows += count; self.reflow_lines(); - self.mark_for_rerender(); } fn reduce_height_up(&mut self, count: usize) { self.position_and_size.rows -= count; self.reflow_lines(); - self.mark_for_rerender(); } fn reduce_width_right(&mut self, count: usize) { self.position_and_size.x += count; self.position_and_size.columns -= count; self.reflow_lines(); - self.mark_for_rerender(); } fn reduce_width_left(&mut self, count: usize) { self.position_and_size.columns -= count; self.reflow_lines(); - self.mark_for_rerender(); } fn increase_width_left(&mut self, count: usize) { self.position_and_size.x -= count; self.position_and_size.columns += count; self.reflow_lines(); - self.mark_for_rerender(); } fn increase_width_right(&mut self, count: usize) { self.position_and_size.columns += count; self.reflow_lines(); - self.mark_for_rerender(); } fn scroll_up(&mut self, count: usize) { self.grid.move_viewport_up(count); diff --git a/src/client/tab.rs b/src/client/tab.rs index 1ef0b720..520720c0 100644 --- a/src/client/tab.rs +++ b/src/client/tab.rs @@ -1679,7 +1679,6 @@ impl Tab { } else if self.can_reduce_pane_and_surroundings_right(&active_pane_id, count) { self.reduce_pane_and_surroundings_right(&active_pane_id, count); } - self.render(); } } pub fn resize_left(&mut self) { @@ -1691,7 +1690,6 @@ impl Tab { } else if self.can_reduce_pane_and_surroundings_left(&active_pane_id, count) { self.reduce_pane_and_surroundings_left(&active_pane_id, count); } - self.render(); } } pub fn resize_down(&mut self) { @@ -1703,7 +1701,6 @@ impl Tab { } else if self.can_reduce_pane_and_surroundings_down(&active_pane_id, count) { self.reduce_pane_and_surroundings_down(&active_pane_id, count); } - self.render(); } } pub fn resize_up(&mut self) { @@ -1715,7 +1712,6 @@ impl Tab { } else if self.can_reduce_pane_and_surroundings_up(&active_pane_id, count) { self.reduce_pane_and_surroundings_up(&active_pane_id, count); } - self.render(); } } pub fn move_focus(&mut self) { diff --git a/src/tests/fakes.rs b/src/tests/fakes.rs index fa9c6f0e..c800de97 100644 --- a/src/tests/fakes.rs +++ b/src/tests/fakes.rs @@ -10,6 +10,8 @@ use std::time::{Duration, Instant}; use crate::os_input_output::OsApi; use crate::tests::possible_tty_inputs::{get_possible_tty_inputs, Bytes}; +use crate::tests::utils::commands::SLEEP; + const MIN_TIME_BETWEEN_SNAPSHOTS: Duration = Duration::from_millis(50); #[derive(Clone)] @@ -189,11 +191,16 @@ impl OsApi for FakeInputOutput { ::std::thread::sleep(MIN_TIME_BETWEEN_SNAPSHOTS - last_snapshot_time.elapsed()); } } - self.stdin_commands + let command = self + .stdin_commands .lock() .unwrap() .pop_front() - .unwrap_or(vec![]) + .unwrap_or(vec![]); + if command == SLEEP { + std::thread::sleep(std::time::Duration::from_millis(200)); + } + command } fn get_stdout_writer(&self) -> Box { Box::new(self.stdout_writer.clone()) diff --git a/src/tests/integration/expansion_boundary.rs b/src/tests/integration/expansion_boundary.rs index 7cb0b0f7..c68c1d5a 100644 --- a/src/tests/integration/expansion_boundary.rs +++ b/src/tests/integration/expansion_boundary.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use crate::panes::PositionAndSize; use crate::tests::fakes::FakeInputOutput; use crate::tests::utils::commands::{ - PANE_MODE, QUIT, RESIZE_DOWN_IN_RESIZE_MODE, RESIZE_MODE, SPAWN_TERMINAL_IN_PANE_MODE, + PANE_MODE, QUIT, RESIZE_DOWN_IN_RESIZE_MODE, RESIZE_MODE, SLEEP, SPAWN_TERMINAL_IN_PANE_MODE, TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE, }; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; @@ -23,7 +23,12 @@ pub fn new_panes_are_open_inside_expansion_border() { y: 0, }; let mut fake_input_output = get_fake_os_input(&fake_win_size); - fake_input_output.add_terminal_input(&[&PANE_MODE, &SPAWN_TERMINAL_IN_PANE_MODE, &QUIT]); + fake_input_output.add_terminal_input(&[ + &PANE_MODE, + &SPAWN_TERMINAL_IN_PANE_MODE, + &SLEEP, + &QUIT, + ]); let mut opts = CliArgs::default(); opts.layout = Some(PathBuf::from( "src/tests/fixtures/layouts/expansion-boundary-in-the-middle.yaml", @@ -55,6 +60,7 @@ pub fn resize_pane_inside_expansion_border() { &SPAWN_TERMINAL_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); let mut opts = CliArgs::default(); @@ -87,6 +93,7 @@ pub fn toggling_fullcsreen_in_expansion_border_expands_only_until_border() { &PANE_MODE, &SPAWN_TERMINAL_IN_PANE_MODE, &TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE, + &SLEEP, &QUIT, ]); let mut opts = CliArgs::default(); diff --git a/src/tests/integration/resize_down.rs b/src/tests/integration/resize_down.rs index 0171cea2..4957b33e 100644 --- a/src/tests/integration/resize_down.rs +++ b/src/tests/integration/resize_down.rs @@ -7,7 +7,8 @@ use crate::{start, CliArgs}; use crate::tests::utils::commands::{ MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_DOWN_IN_RESIZE_MODE, - RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, + RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, SLEEP, SPLIT_DOWN_IN_PANE_MODE, + SPLIT_RIGHT_IN_PANE_MODE, }; fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput { @@ -37,6 +38,7 @@ pub fn resize_down_with_pane_above() { &SPLIT_DOWN_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); @@ -75,6 +77,7 @@ pub fn resize_down_with_pane_below() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); @@ -118,6 +121,7 @@ pub fn resize_down_with_panes_above_and_below() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); @@ -160,6 +164,7 @@ pub fn resize_down_with_multiple_panes_above() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -205,6 +210,7 @@ pub fn resize_down_with_panes_above_aligned_left_with_current_pane() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -249,6 +255,7 @@ pub fn resize_down_with_panes_below_aligned_left_with_current_pane() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -291,6 +298,7 @@ pub fn resize_down_with_panes_above_aligned_right_with_current_pane() { &SPLIT_DOWN_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -334,6 +342,7 @@ pub fn resize_down_with_panes_below_aligned_right_with_current_pane() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -380,6 +389,7 @@ pub fn resize_down_with_panes_above_aligned_left_and_right_with_current_pane() { &SPLIT_DOWN_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -428,6 +438,7 @@ pub fn resize_down_with_panes_below_aligned_left_and_right_with_current_pane() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -493,6 +504,7 @@ pub fn resize_down_with_panes_above_aligned_left_and_right_with_panes_to_the_lef &RESIZE_LEFT_IN_RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -560,6 +572,7 @@ pub fn resize_down_with_panes_below_aligned_left_and_right_with_to_the_left_and_ &RESIZE_LEFT_IN_RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -596,6 +609,7 @@ pub fn cannot_resize_down_when_pane_below_is_at_minimum_height() { &SPLIT_DOWN_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); diff --git a/src/tests/integration/resize_left.rs b/src/tests/integration/resize_left.rs index 0d0d61a5..a9d229d9 100644 --- a/src/tests/integration/resize_left.rs +++ b/src/tests/integration/resize_left.rs @@ -7,7 +7,7 @@ use crate::{start, CliArgs}; use crate::tests::utils::commands::{ MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, - RESIZE_UP_IN_RESIZE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, + RESIZE_UP_IN_RESIZE_MODE, SLEEP, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, }; fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput { @@ -34,6 +34,7 @@ pub fn resize_left_with_pane_to_the_left() { &SPLIT_RIGHT_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); @@ -70,6 +71,7 @@ pub fn resize_left_with_pane_to_the_right() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); @@ -108,6 +110,7 @@ pub fn resize_left_with_panes_to_the_left_and_right() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); @@ -148,6 +151,7 @@ pub fn resize_left_with_multiple_panes_to_the_left() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -191,6 +195,7 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_with_current_pane() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -231,6 +236,7 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_with_current_pane() { &SPLIT_DOWN_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -273,6 +279,7 @@ pub fn resize_left_with_panes_to_the_left_aligned_bottom_with_current_pane() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -314,6 +321,7 @@ pub fn resize_left_with_panes_to_the_right_aligned_bottom_with_current_pane() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -360,6 +368,7 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_and_bottom_with_current_pa &SPLIT_RIGHT_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -408,6 +417,7 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_and_bottom_with_current_p &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -473,6 +483,7 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_and_bottom_with_panes_abov &RESIZE_UP_IN_RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -541,6 +552,7 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_and_bottom_with_panes_abo &RESIZE_UP_IN_RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -577,6 +589,7 @@ pub fn cannot_resize_left_when_pane_to_the_left_is_at_minimum_width() { &SPLIT_RIGHT_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); diff --git a/src/tests/integration/resize_right.rs b/src/tests/integration/resize_right.rs index 8f1928ee..fef33e84 100644 --- a/src/tests/integration/resize_right.rs +++ b/src/tests/integration/resize_right.rs @@ -7,7 +7,7 @@ use crate::{start, CliArgs}; use crate::tests::utils::commands::{ MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_MODE, RESIZE_RIGHT_IN_RESIZE_MODE, - RESIZE_UP_IN_RESIZE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, + RESIZE_UP_IN_RESIZE_MODE, SLEEP, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, }; fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput { @@ -34,6 +34,7 @@ pub fn resize_right_with_pane_to_the_left() { &SPLIT_RIGHT_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_RIGHT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); @@ -70,6 +71,7 @@ pub fn resize_right_with_pane_to_the_right() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_RIGHT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); @@ -108,6 +110,7 @@ pub fn resize_right_with_panes_to_the_left_and_right() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_RIGHT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); @@ -148,6 +151,7 @@ pub fn resize_right_with_multiple_panes_to_the_left() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_RIGHT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -191,6 +195,7 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_with_current_pane() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_RIGHT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -231,6 +236,7 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_with_current_pane() { &SPLIT_DOWN_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_RIGHT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -273,6 +279,7 @@ pub fn resize_right_with_panes_to_the_left_aligned_bottom_with_current_pane() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_RIGHT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -314,6 +321,7 @@ pub fn resize_right_with_panes_to_the_right_aligned_bottom_with_current_pane() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_RIGHT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -360,6 +368,7 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_current_p &SPLIT_RIGHT_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_RIGHT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -408,6 +417,7 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_current_ &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_RIGHT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -473,6 +483,7 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_panes_abo &RESIZE_UP_IN_RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, &RESIZE_RIGHT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -540,6 +551,7 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_panes_ab &RESIZE_UP_IN_RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, &RESIZE_RIGHT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -576,6 +588,7 @@ pub fn cannot_resize_right_when_pane_to_the_left_is_at_minimum_width() { &SPLIT_RIGHT_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_RIGHT_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); diff --git a/src/tests/integration/resize_up.rs b/src/tests/integration/resize_up.rs index 2df6dfa7..9d4dd05a 100644 --- a/src/tests/integration/resize_up.rs +++ b/src/tests/integration/resize_up.rs @@ -7,7 +7,7 @@ use crate::{start, CliArgs}; use crate::tests::utils::commands::{ MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, - RESIZE_UP_IN_RESIZE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, + RESIZE_UP_IN_RESIZE_MODE, SLEEP, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, }; fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput { @@ -36,6 +36,7 @@ pub fn resize_up_with_pane_above() { &SPLIT_DOWN_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); @@ -74,6 +75,7 @@ pub fn resize_up_with_pane_below() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); @@ -117,6 +119,7 @@ pub fn resize_up_with_panes_above_and_below() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); @@ -158,6 +161,7 @@ pub fn resize_up_with_multiple_panes_above() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -201,6 +205,7 @@ pub fn resize_up_with_panes_above_aligned_left_with_current_pane() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -245,6 +250,7 @@ pub fn resize_up_with_panes_below_aligned_left_with_current_pane() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -287,6 +293,7 @@ pub fn resize_up_with_panes_above_aligned_right_with_current_pane() { &SPLIT_DOWN_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -330,6 +337,7 @@ pub fn resize_up_with_panes_below_aligned_right_with_current_pane() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -376,6 +384,7 @@ pub fn resize_up_with_panes_above_aligned_left_and_right_with_current_pane() { &SPLIT_DOWN_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -424,6 +433,7 @@ pub fn resize_up_with_panes_below_aligned_left_and_right_with_current_pane() { &MOVE_FOCUS_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -489,6 +499,7 @@ pub fn resize_up_with_panes_above_aligned_left_and_right_with_panes_to_the_left_ &RESIZE_LEFT_IN_RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -556,6 +567,7 @@ pub fn resize_up_with_panes_below_aligned_left_and_right_with_to_the_left_and_ri &RESIZE_LEFT_IN_RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); @@ -592,6 +604,7 @@ pub fn cannot_resize_up_when_pane_above_is_at_minimum_height() { &SPLIT_DOWN_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, + &SLEEP, &QUIT, ]); start(Box::new(fake_input_output.clone()), CliArgs::default()); diff --git a/src/tests/utils.rs b/src/tests/utils.rs index 86973d74..14f4cfa0 100644 --- a/src/tests/utils.rs +++ b/src/tests/utils.rs @@ -76,4 +76,5 @@ pub mod commands { pub const SWITCH_NEXT_TAB_IN_TAB_MODE: [u8; 1] = [108]; // l pub const SWITCH_PREV_TAB_IN_TAB_MODE: [u8; 1] = [104]; // h pub const CLOSE_TAB_IN_TAB_MODE: [u8; 1] = [120]; // x + pub const SLEEP: [u8; 0] = []; }