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 Binary files /dev/null and b/src/tests/fixtures/bash_cursor_linewrap 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 +█ + + + + + + + + + + + + + + + + + + + + + + + +