aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2020-12-17 16:33:18 +0100
committerGitHub <noreply@github.com>2020-12-17 16:33:18 +0100
commit97980d618f9a79321b511fd23a114eef88c8632f (patch)
treef4c00508b2203a86a1c35473d4f4acddac67b924 /src
parentfix(compatibility): fix neovim change mode (#108) (diff)
downloadsl0ppij-97980d618f9a79321b511fd23a114eef88c8632f.tar.gz
sl0ppij-97980d618f9a79321b511fd23a114eef88c8632f.tar.xz
sl0ppij-97980d618f9a79321b511fd23a114eef88c8632f.zip
fix(compatibility): fix bash linewrap (#109)
Diffstat (limited to 'src')
-rw-r--r--src/terminal_pane/scroll.rs2
-rw-r--r--src/tests/fixtures/bash_cursor_linewrapbin0 -> 1346 bytes
-rw-r--r--src/tests/integration/compatibility.rs25
-rw-r--r--src/tests/integration/snapshots/mosaic__tests__integration__compatibility__bash_cursor_linewrap-2.snap32
-rw-r--r--src/tests/integration/snapshots/mosaic__tests__integration__compatibility__bash_cursor_linewrap.snap32
5 files changed, 90 insertions, 1 deletions
diff --git a/src/terminal_pane/scroll.rs b/src/terminal_pane/scroll.rs
index 8bd304f1..f86cf5f8 100644
--- a/src/terminal_pane/scroll.rs
+++ b/src/terminal_pane/scroll.rs
@@ -384,7 +384,7 @@ impl Scroll {
.get_mut(wrapped_fragment_index_in_line)
.expect("cursor out of bounds");
- if cursor_position_in_line <= self.total_columns {
+ if cursor_position_in_line < self.total_columns {
current_wrapped_fragment.add_character(terminal_character, cursor_position_in_line);
self.cursor_position.move_forward(1);
} else {
diff --git a/src/tests/fixtures/bash_cursor_linewrap b/src/tests/fixtures/bash_cursor_linewrap
new file mode 100644
index 00000000..2e183a1f
--- /dev/null
+++ b/src/tests/fixtures/bash_cursor_linewrap
Binary files differ
diff --git a/src/tests/integration/compatibility.rs b/src/tests/integration/compatibility.rs
index 467a99ca..65dc8da9 100644
--- a/src/tests/integration/compatibility.rs
+++ b/src/tests/integration/compatibility.rs
@@ -363,3 +363,28 @@ pub fn neovim_insert_mode() {
assert_snapshot!(snapshot);
}
}
+
+#[test]
+pub fn bash_cursor_linewrap() {
+ // this test makes sure that when we enter a command that is beyond the screen border, that it
+ // immediately goes down one line
+ let fake_win_size = PositionAndSize {
+ columns: 116,
+ rows: 28,
+ x: 0,
+ y: 0,
+ };
+ let fixture_name = "bash_cursor_linewrap";
+ let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
+ fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &COMMAND_TOGGLE, &QUIT]);
+ start(Box::new(fake_input_output.clone()), Opt::default());
+ 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__bash_cursor_linewrap-2.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__bash_cursor_linewrap-2.snap
new file mode 100644
index 00000000..a07cffba
--- /dev/null
+++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__bash_cursor_linewrap-2.snap
@@ -0,0 +1,32 @@
+---
+source: src/tests/integration/compatibility.rs
+expression: snapshot
+---
+⋊> ~/c/mosaic on main ⨯ bash 16:00:06
+[aram@green mosaic]$ 12345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Bye from Mosaic!█
diff --git a/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__bash_cursor_linewrap.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__bash_cursor_linewrap.snap
new file mode 100644
index 00000000..2736e8b8
--- /dev/null
+++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__bash_cursor_linewrap.snap
@@ -0,0 +1,32 @@
+---
+source: src/tests/integration/compatibility.rs
+expression: snapshot
+---
+Welcome to fish, the friendly interactive shell
+⋊> ~/c/mosaic on main ⨯ bash 16:00:06
+[aram@green mosaic]$ 12345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345
+█
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+