aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2020-10-05 16:46:40 +0200
committerAram Drevekenin <aram@poor.dev>2020-10-05 16:46:40 +0200
commit5cd365a73ce83991b98a92b41a5e1994afaa1688 (patch)
tree86ece9fab529737b70696c926fd3edfb768c5629 /src/tests
parentrefactor(terminal): minor cleanups (diff)
downloadsl0ppij-5cd365a73ce83991b98a92b41a5e1994afaa1688.tar.gz
sl0ppij-5cd365a73ce83991b98a92b41a5e1994afaa1688.tar.xz
sl0ppij-5cd365a73ce83991b98a92b41a5e1994afaa1688.zip
feat(compatibility): vim working!
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/fixtures/vim_ctrl_dbin0 -> 3698 bytes
-rw-r--r--src/tests/fixtures/vim_ctrl_ubin0 -> 4994 bytes
-rw-r--r--src/tests/fixtures/vim_scroll_region_downbin0 -> 3829 bytes
-rw-r--r--src/tests/integration/compatibility.rs77
-rw-r--r--src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_d-2.snap32
-rw-r--r--src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_d.snap32
-rw-r--r--src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_u-2.snap32
-rw-r--r--src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_u.snap32
-rw-r--r--src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_scroll_region_down-2.snap32
-rw-r--r--src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_scroll_region_down.snap32
10 files changed, 269 insertions, 0 deletions
diff --git a/src/tests/fixtures/vim_ctrl_d b/src/tests/fixtures/vim_ctrl_d
new file mode 100644
index 00000000..1f4929b8
--- /dev/null
+++ b/src/tests/fixtures/vim_ctrl_d
Binary files differ
diff --git a/src/tests/fixtures/vim_ctrl_u b/src/tests/fixtures/vim_ctrl_u
new file mode 100644
index 00000000..063eb231
--- /dev/null
+++ b/src/tests/fixtures/vim_ctrl_u
Binary files differ
diff --git a/src/tests/fixtures/vim_scroll_region_down b/src/tests/fixtures/vim_scroll_region_down
new file mode 100644
index 00000000..cd2061d2
--- /dev/null
+++ b/src/tests/fixtures/vim_scroll_region_down
Binary files differ
diff --git a/src/tests/integration/compatibility.rs b/src/tests/integration/compatibility.rs
index e5e10061..cd04d354 100644
--- a/src/tests/integration/compatibility.rs
+++ b/src/tests/integration/compatibility.rs
@@ -88,3 +88,80 @@ pub fn fish_select_tab_completion_options() {
assert_snapshot!(snapshot);
}
}
+
+#[test]
+pub fn vim_scroll_region_down () {
+ // here we test a case where vim defines the scroll region as lesser than the screen row count
+ // and then scrolls down
+ // the region is defined here by vim as 1-26 (there are 28 rows)
+ // then the cursor is moved to line 26 and a new line is added
+ // what should happen is that the first line in the scroll region (1) is deleted
+ // and an empty line is inserted in the last scroll region line (26)
+ // this tests also has other steps afterwards that fills the line with the next line in the
+ // file
+ // experience appear to the user
+ let fake_win_size = Winsize {
+ ws_col: 116,
+ ws_row: 28,
+ ws_xpixel: 0,
+ ws_ypixel: 0,
+ };
+ let fixture_name = "vim_scroll_region_down";
+ let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
+ fake_input_output.add_terminal_input(&[17]); // quit (ctrl-q)
+ start(Box::new(fake_input_output.clone()));
+ let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap();
+ let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
+ for snapshot in snapshots {
+ assert_snapshot!(snapshot);
+ }
+}
+
+#[test]
+pub fn vim_ctrl_d() {
+ // in vim ctrl-d moves down half a page
+ // in this case, it sends the terminal the csi 'M' directive, which tells it to delete X (13 in
+ // this case) lines inside the scroll region and push the other lines up
+ // what happens here is that 13 lines are deleted and instead 13 empty lines are added at the
+ // end of the scroll region
+ // vim makes sure to fill these empty lines with the rest of the file
+ let fake_win_size = Winsize {
+ ws_col: 116,
+ ws_row: 28,
+ ws_xpixel: 0,
+ ws_ypixel: 0,
+ };
+ let fixture_name = "vim_ctrl_d";
+ let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
+ fake_input_output.add_terminal_input(&[17]); // quit (ctrl-q)
+ start(Box::new(fake_input_output.clone()));
+ let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap();
+ let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
+ for snapshot in snapshots {
+ assert_snapshot!(snapshot);
+ }
+}
+
+#[test]
+pub fn vim_ctrl_u() {
+ // in vim ctrl-u moves up half a page
+ // in this case, it sends the terminal the csi 'L' directive, which tells it to insert X (13 in
+ // this case) lines at the cursor, pushing away (deleting) the last line in the scroll region
+ // this causes the effect of scrolling up X lines (vim replaces the lines with the ones in the
+ // file above the current content)
+ let fake_win_size = Winsize {
+ ws_col: 116,
+ ws_row: 28,
+ ws_xpixel: 0,
+ ws_ypixel: 0,
+ };
+ let fixture_name = "vim_ctrl_u";
+ let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
+ fake_input_output.add_terminal_input(&[17]); // quit (ctrl-q)
+ start(Box::new(fake_input_output.clone()));
+ let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap();
+ let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
+ for snapshot in snapshots {
+ assert_snapshot!(snapshot);
+ }
+}
diff --git a/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_d-2.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_d-2.snap
new file mode 100644
index 00000000..5a3f7ce5
--- /dev/null
+++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_d-2.snap
@@ -0,0 +1,32 @@
+---
+source: src/tests/integration/compatibility.rs
+expression: snapshot
+---
+ 2 line15
+ 1 line16
+17 line17
+ 1 line18
+ 2 line19
+ 3 line20
+ 4 line21
+ 5 line22
+ 6 line23
+ 7 line24
+ 8 line25
+ 9 line26
+ 10 line27
+ 11 line28
+ 12 line29
+ 13 line30
+ 14 line31
+ 15 line32
+ 16 line33
+ 17 line34
+ 18 line35
+ 19 line36
+ 20 line37
+ 21 line38
+ 22 line39
+ NORMAL testfile.rs unix | utf-8 | rust 40% 17:1
+"/tmp/testfile.rs" 42L, 285C
+Bye from Mosaic!█
diff --git a/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_d.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_d.snap
new file mode 100644
index 00000000..b4eee2ea
--- /dev/null
+++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_d.snap
@@ -0,0 +1,32 @@
+---
+source: src/tests/integration/compatibility.rs
+expression: snapshot
+---
+ 3 line14
+ 2 line15
+ 1 line16
+17 █ine17
+ 1 line18
+ 2 line19
+ 3 line20
+ 4 line21
+ 5 line22
+ 6 line23
+ 7 line24
+ 8 line25
+ 9 line26
+ 10 line27
+ 11 line28
+ 12 line29
+ 13 line30
+ 14 line31
+ 15 line32
+ 16 line33
+ 17 line34
+ 18 line35
+ 19 line36
+ 20 line37
+ 21 line38
+ 22 line39
+ NORMAL testfile.rs unix | utf-8 | rust 40% 17:1
+"/tmp/testfile.rs" 42L, 285C
diff --git a/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_u-2.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_u-2.snap
new file mode 100644
index 00000000..82d924a0
--- /dev/null
+++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_u-2.snap
@@ -0,0 +1,32 @@
+---
+source: src/tests/integration/compatibility.rs
+expression: snapshot
+---
+ 21 line5
+ 20 line6
+ 19 line7
+ 18 line8
+ 17 line9
+ 16 line10
+ 15 line11
+ 14 line12
+ 13 line13
+ 12 line14
+ 11 line15
+ 10 line16
+ 9 line17
+ 8 line18
+ 7 line19
+ 6 line20
+ 5 line21
+ 4 line22
+ 3 line23
+ 2 line24
+ 1 line25
+26 line26
+ 1 line27
+ 2 line28
+ 3 line29
+ NORMAL testfile.rs unix | utf-8 | rust 61% 26:1
+"/tmp/testfile.rs" 42L, 285C
+Bye from Mosaic!█
diff --git a/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_u.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_u.snap
new file mode 100644
index 00000000..cdb821f9
--- /dev/null
+++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_ctrl_u.snap
@@ -0,0 +1,32 @@
+---
+source: src/tests/integration/compatibility.rs
+expression: snapshot
+---
+ 22 line4
+ 21 line5
+ 20 line6
+ 19 line7
+ 18 line8
+ 17 line9
+ 16 line10
+ 15 line11
+ 14 line12
+ 13 line13
+ 12 line14
+ 11 line15
+ 10 line16
+ 9 line17
+ 8 line18
+ 7 line19
+ 6 line20
+ 5 line21
+ 4 line22
+ 3 line23
+ 2 line24
+ 1 line25
+26 █ine26
+ 1 line27
+ 2 line28
+ 3 line29
+ NORMAL testfile.rs unix | utf-8 | rust 61% 26:1
+"/tmp/testfile.rs" 42L, 285C
diff --git a/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_scroll_region_down-2.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_scroll_region_down-2.snap
new file mode 100644
index 00000000..a897b376
--- /dev/null
+++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_scroll_region_down-2.snap
@@ -0,0 +1,32 @@
+---
+source: src/tests/integration/compatibility.rs
+expression: snapshot
+---
+ 21 line3
+ 20 line4
+ 19 line5
+ 18 line6
+ 17 line7
+ 16 line8
+ 15 line9
+ 14 line10
+ 13 line11
+ 12 line12
+ 11 line13
+ 10 line14
+ 9 line15
+ 8 line16
+ 7 line17
+ 6 line18
+ 5 line19
+ 4 line20
+ 3 line21
+ 2 line22
+ 1 line23
+24 line24
+ 1 line25
+ 2 line26
+ 3 line27
+ NORMAL testfile.rs unix | utf-8 | rust 57% 24:1
+"/tmp/testfile.rs" 42L, 285C
+Bye from Mosaic!█
diff --git a/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_scroll_region_down.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_scroll_region_down.snap
new file mode 100644
index 00000000..3ca2370e
--- /dev/null
+++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_scroll_region_down.snap
@@ -0,0 +1,32 @@
+---
+source: src/tests/integration/compatibility.rs
+expression: snapshot
+---
+ 22 line2
+ 21 line3
+ 20 line4
+ 19 line5
+ 18 line6
+ 17 line7
+ 16 line8
+ 15 line9
+ 14 line10
+ 13 line11
+ 12 line12
+ 11 line13
+ 10 line14
+ 9 line15
+ 8 line16
+ 7 line17
+ 6 line18
+ 5 line19
+ 4 line20
+ 3 line21
+ 2 line22
+ 1 line23
+24 █ine24
+ 1 line25
+ 2 line26
+ 3 line27
+ NORMAL testfile.rs unix | utf-8 | rust 57% 24:1
+"/tmp/testfile.rs" 42L, 285C