aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCosmin Popescu <cosminadrianpopescu@gmail.com>2022-06-06 09:20:07 +0200
committerGitHub <noreply@github.com>2022-06-06 09:20:07 +0200
commite1fcf3a6dbc7a65a341127fab2fca7b4fb2d081b (patch)
treeec1061b57347348f081d64c532f7fc12ff21c4dd /src
parentflake.lock: Update (#1455) (diff)
downloadsl0ppij-e1fcf3a6dbc7a65a341127fab2fca7b4fb2d081b.tar.gz
sl0ppij-e1fcf3a6dbc7a65a341127fab2fca7b4fb2d081b.tar.xz
sl0ppij-e1fcf3a6dbc7a65a341127fab2fca7b4fb2d081b.zip
feat(scroll): edit scrollback with default editor (#1456)
* initial commit for opening the current buffer in an editor * fix(editor): take hidden panes into consideration when manipulating tiled grid * when closing an edit buffer, take the geometry of the replaced buffer from the closed buffer * if the floating panels are displayed, don't add to hidden panels the current buffer * strategy changing - put the panels inside a suppressed_panels HashMap instead of hidden_panels * Revert "strategy changing - put the panels inside a suppressed_panels HashMap instead of hidden_panels" This reverts commit c52a203a20cf4c87c147be8b9c193ed6458c1038. * remove the floating panes by moving them to the tiled_panes in hidden_panels * feat(edit): open editor to correct line and don't crash when none is set * formatting * feat(edit): use suppressed panes * style(fmt): rustfmt and logs * style(fmt): clean up unused code * test(editor): integration test for suppressing/closing suppressed pane * test(e2e): editor e2e test * style(fmt): rustfmt * feat(edit): update ui and setup * style(fmt): rustfmt * feat(config): allow configuring scrollback_editor explicitly * style(fmt): rustfmt * chore(repo): build after merging Co-authored-by: Aram Drevekenin <aram@poor.dev>
Diffstat (limited to 'src')
-rw-r--r--src/tests/e2e/cases.rs49
-rw-r--r--src/tests/e2e/remote_runner.rs37
-rw-r--r--src/tests/e2e/snapshots/zellij__tests__e2e__cases__scrolling_inside_a_pane.snap4
3 files changed, 77 insertions, 13 deletions
diff --git a/src/tests/e2e/cases.rs b/src/tests/e2e/cases.rs
index 92438525..00cf2715 100644
--- a/src/tests/e2e/cases.rs
+++ b/src/tests/e2e/cases.rs
@@ -38,6 +38,7 @@ pub const SCROLL_UP_IN_SCROLL_MODE: [u8; 1] = [107]; // k
pub const SCROLL_DOWN_IN_SCROLL_MODE: [u8; 1] = [106]; // j
pub const SCROLL_PAGE_UP_IN_SCROLL_MODE: [u8; 1] = [2]; // ctrl-b
pub const SCROLL_PAGE_DOWN_IN_SCROLL_MODE: [u8; 1] = [6]; // ctrl-f
+pub const EDIT_SCROLLBACK: [u8; 1] = [101]; // e
pub const RESIZE_MODE: [u8; 1] = [14]; // ctrl-n
pub const RESIZE_DOWN_IN_RESIZE_MODE: [u8; 1] = [106]; // j
@@ -1804,3 +1805,51 @@ pub fn tmux_mode() {
};
assert_snapshot!(last_snapshot);
}
+
+#[test]
+#[ignore]
+pub fn edit_scrollback() {
+ let fake_win_size = Size {
+ cols: 120,
+ rows: 24,
+ };
+
+ let mut test_attempts = 10;
+ let last_snapshot = loop {
+ RemoteRunner::kill_running_sessions(fake_win_size);
+ let mut runner = RemoteRunner::new(fake_win_size).add_step(Step {
+ name: "Split pane to the right",
+ instruction: |mut remote_terminal: RemoteTerminal| -> bool {
+ let mut step_is_complete = false;
+ if remote_terminal.status_bar_appears() && remote_terminal.cursor_position_is(3, 2)
+ {
+ remote_terminal.send_key(&SCROLL_MODE);
+ remote_terminal.send_key(&EDIT_SCROLLBACK);
+ step_is_complete = true;
+ }
+ step_is_complete
+ },
+ });
+ runner.run_all_steps();
+ let last_snapshot = runner.take_snapshot_after(Step {
+ name: "Wait for editor to appear",
+ instruction: |remote_terminal: RemoteTerminal| -> bool {
+ let mut step_is_complete = false;
+ if remote_terminal.snapshot_contains(".dump") {
+ // the .dump is an indication we get on the bottom line of vi when editing a
+ // file
+ // the temp file name is randomly generated, so we don't assert the whole snapshot
+ step_is_complete = true;
+ }
+ step_is_complete
+ },
+ });
+ if runner.test_timed_out && test_attempts > 0 {
+ test_attempts -= 1;
+ continue;
+ } else {
+ break last_snapshot;
+ }
+ };
+ assert!(last_snapshot.contains(".dump"));
+}
diff --git a/src/tests/e2e/remote_runner.rs b/src/tests/e2e/remote_runner.rs
index 466b1805..564714bb 100644
--- a/src/tests/e2e/remote_runner.rs
+++ b/src/tests/e2e/remote_runner.rs
@@ -17,6 +17,7 @@ use std::cell::RefCell;
use std::rc::Rc;
const ZELLIJ_EXECUTABLE_LOCATION: &str = "/usr/src/zellij/x86_64-unknown-linux-musl/release/zellij";
+const SET_ENV_VARIABLES: &str = "EDITOR=/usr/bin/vi";
const ZELLIJ_LAYOUT_PATH: &str = "/usr/src/zellij/fixtures/layouts";
const ZELLIJ_DATA_DIR: &str = "/usr/src/zellij/e2e-data";
const CONNECTION_STRING: &str = "127.0.0.1:2222";
@@ -64,8 +65,8 @@ fn start_zellij(channel: &mut ssh2::Channel) {
channel
.write_all(
format!(
- "{} --session {} --data-dir {}\n",
- ZELLIJ_EXECUTABLE_LOCATION, SESSION_NAME, ZELLIJ_DATA_DIR
+ "{} {} --session {} --data-dir {}\n",
+ SET_ENV_VARIABLES, ZELLIJ_EXECUTABLE_LOCATION, SESSION_NAME, ZELLIJ_DATA_DIR
)
.as_bytes(),
)
@@ -78,8 +79,8 @@ fn start_zellij_mirrored_session(channel: &mut ssh2::Channel) {
channel
.write_all(
format!(
- "{} --session {} --data-dir {} options --mirror-session true\n",
- ZELLIJ_EXECUTABLE_LOCATION, SESSION_NAME, ZELLIJ_DATA_DIR
+ "{} {} --session {} --data-dir {} options --mirror-session true\n",
+ SET_ENV_VARIABLES, ZELLIJ_EXECUTABLE_LOCATION, SESSION_NAME, ZELLIJ_DATA_DIR
)
.as_bytes(),
)
@@ -92,8 +93,12 @@ fn start_zellij_in_session(channel: &mut ssh2::Channel, session_name: &str, mirr
channel
.write_all(
format!(
- "{} --session {} --data-dir {} options --mirror-session {}\n",
- ZELLIJ_EXECUTABLE_LOCATION, session_name, ZELLIJ_DATA_DIR, mirrored
+ "{} {} --session {} --data-dir {} options --mirror-session {}\n",
+ SET_ENV_VARIABLES,
+ ZELLIJ_EXECUTABLE_LOCATION,
+ session_name,
+ ZELLIJ_DATA_DIR,
+ mirrored
)
.as_bytes(),
)
@@ -103,7 +108,13 @@ fn start_zellij_in_session(channel: &mut ssh2::Channel, session_name: &str, mirr
fn attach_to_existing_session(channel: &mut ssh2::Channel, session_name: &str) {
channel
- .write_all(format!("{} attach {}\n", ZELLIJ_EXECUTABLE_LOCATION, session_name).as_bytes())
+ .write_all(
+ format!(
+ "{} {} attach {}\n",
+ SET_ENV_VARIABLES, ZELLIJ_EXECUTABLE_LOCATION, session_name
+ )
+ .as_bytes(),
+ )
.unwrap();
channel.flush().unwrap();
}
@@ -113,8 +124,8 @@ fn start_zellij_without_frames(channel: &mut ssh2::Channel) {
channel
.write_all(
format!(
- "{} --session {} --data-dir {} options --no-pane-frames\n",
- ZELLIJ_EXECUTABLE_LOCATION, SESSION_NAME, ZELLIJ_DATA_DIR
+ "{} {} --session {} --data-dir {} options --no-pane-frames\n",
+ SET_ENV_VARIABLES, ZELLIJ_EXECUTABLE_LOCATION, SESSION_NAME, ZELLIJ_DATA_DIR
)
.as_bytes(),
)
@@ -127,8 +138,12 @@ fn start_zellij_with_layout(channel: &mut ssh2::Channel, layout_path: &str) {
channel
.write_all(
format!(
- "{} --layout {} --session {} --data-dir {}\n",
- ZELLIJ_EXECUTABLE_LOCATION, layout_path, SESSION_NAME, ZELLIJ_DATA_DIR
+ "{} {} --layout {} --session {} --data-dir {}\n",
+ SET_ENV_VARIABLES,
+ ZELLIJ_EXECUTABLE_LOCATION,
+ layout_path,
+ SESSION_NAME,
+ ZELLIJ_DATA_DIR
)
.as_bytes(),
)
diff --git a/src/tests/e2e/snapshots/zellij__tests__e2e__cases__scrolling_inside_a_pane.snap b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__scrolling_inside_a_pane.snap
index 664e881b..422a5616 100644
--- a/src/tests/e2e/snapshots/zellij__tests__e2e__cases__scrolling_inside_a_pane.snap
+++ b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__scrolling_inside_a_pane.snap
@@ -1,7 +1,7 @@
---
source: src/tests/e2e/cases.rs
+assertion_line: 295
expression: last_snapshot
-
---
Zellij (e2e-test)  Tab #1 
┌ Pane #1 ─────────────────────────────────────────────────┐┌ Pane #2 ─────────────────────────────────── SCROLL: 1/1 ┐
@@ -26,4 +26,4 @@ expression: last_snapshot
│ ││line19 00000000000000000000000000000000000000000000000000█│
└──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SCROLL  <o> SESSION  <q> QUIT 
- <↓↑> Scroll / <PgUp/PgDn> Scroll Page / <u/d> Scroll Half Page / <ENTER> Select pane
+ <↓↑> Scroll / <PgUp/PgDn> Scroll / <u/d> Scroll / <e> Edit / <ENTER> Select pane