fix(compatibility): git log and git diff with scrollup (#118)
* fix(compatibility): git log and git diff with scrollup * style(formatting): make rustfmt happy
This commit is contained in:
parent
75b00b7932
commit
4436c89230
13 changed files with 364 additions and 18 deletions
|
|
@ -661,7 +661,7 @@ impl Scroll {
|
||||||
pub fn move_current_buffer_to_alternative_buffer(&mut self) {
|
pub fn move_current_buffer_to_alternative_buffer(&mut self) {
|
||||||
self.alternative_buffer = Some(self.canonical_lines.drain(..).collect());
|
self.alternative_buffer = Some(self.canonical_lines.drain(..).collect());
|
||||||
self.alternative_cursor_position = Some(self.cursor_position);
|
self.alternative_cursor_position = Some(self.cursor_position);
|
||||||
self.cursor_position.reset();
|
self.clear_all();
|
||||||
}
|
}
|
||||||
pub fn override_current_buffer_with_alternative_buffer(&mut self) {
|
pub fn override_current_buffer_with_alternative_buffer(&mut self) {
|
||||||
if let Some(alternative_buffer) = self.alternative_buffer.as_mut() {
|
if let Some(alternative_buffer) = self.alternative_buffer.as_mut() {
|
||||||
|
|
@ -691,6 +691,19 @@ impl Scroll {
|
||||||
Some((self.scroll_region.unwrap().0, self.scroll_region.unwrap().1))
|
Some((self.scroll_region.unwrap().0, self.scroll_region.unwrap().1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn scroll_region_absolute_indices_or_screen_edges(&mut self) -> (usize, usize) {
|
||||||
|
match self.scroll_region {
|
||||||
|
Some(_scroll_region) => self.scroll_region_absolute_indices().unwrap(),
|
||||||
|
None => {
|
||||||
|
// indices of screen top and bottom edge
|
||||||
|
// TODO: what if we don't have enough lines?
|
||||||
|
// let absolute_top = self.canonical_lines.len() - 1 - self.lines_in_view;
|
||||||
|
let absolute_top = self.canonical_lines.len() - self.lines_in_view;
|
||||||
|
let absolute_bottom = self.canonical_lines.len() - 1;
|
||||||
|
(absolute_top, absolute_bottom)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
pub fn delete_lines_in_scroll_region(&mut self, count: usize) {
|
pub fn delete_lines_in_scroll_region(&mut self, count: usize) {
|
||||||
if let Some((scroll_region_top, scroll_region_bottom)) =
|
if let Some((scroll_region_top, scroll_region_bottom)) =
|
||||||
self.scroll_region_absolute_indices()
|
self.scroll_region_absolute_indices()
|
||||||
|
|
@ -732,10 +745,8 @@ impl Scroll {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn move_cursor_up_in_scroll_region(&mut self, count: usize) {
|
pub fn move_cursor_up_in_scroll_region(&mut self, count: usize) {
|
||||||
if let Some((scroll_region_top, scroll_region_bottom)) =
|
let (scroll_region_top, scroll_region_bottom) =
|
||||||
self.scroll_region_absolute_indices()
|
self.scroll_region_absolute_indices_or_screen_edges();
|
||||||
{
|
|
||||||
// the scroll region indices start at 1, so we need to adjust them
|
|
||||||
for _ in 0..count {
|
for _ in 0..count {
|
||||||
let current_canonical_line_index = self.cursor_position.line_index.0;
|
let current_canonical_line_index = self.cursor_position.line_index.0;
|
||||||
if current_canonical_line_index == scroll_region_top {
|
if current_canonical_line_index == scroll_region_top {
|
||||||
|
|
@ -751,7 +762,6 @@ impl Scroll {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/// [scroll_up](https://github.com/alacritty/alacritty/blob/ec42b42ce601808070462111c0c28edb0e89babb/alacritty_terminal/src/grid/mod.rs#L261)
|
/// [scroll_up](https://github.com/alacritty/alacritty/blob/ec42b42ce601808070462111c0c28edb0e89babb/alacritty_terminal/src/grid/mod.rs#L261)
|
||||||
/// This function takes the first line of the scroll region and moves it to the bottom (count times)
|
/// This function takes the first line of the scroll region and moves it to the bottom (count times)
|
||||||
pub fn rotate_scroll_region_up(&mut self, count: usize) {
|
pub fn rotate_scroll_region_up(&mut self, count: usize) {
|
||||||
|
|
|
||||||
BIN
src/tests/fixtures/git_diff_scrollup
vendored
Normal file
BIN
src/tests/fixtures/git_diff_scrollup
vendored
Normal file
Binary file not shown.
BIN
src/tests/fixtures/git_log
vendored
Normal file
BIN
src/tests/fixtures/git_log
vendored
Normal file
Binary file not shown.
|
|
@ -413,3 +413,51 @@ pub fn fish_paste_multiline() {
|
||||||
assert_snapshot!(snapshot);
|
assert_snapshot!(snapshot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
pub fn git_log() {
|
||||||
|
let fake_win_size = PositionAndSize {
|
||||||
|
columns: 149,
|
||||||
|
rows: 28,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
};
|
||||||
|
let fixture_name = "git_log";
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
pub fn git_diff_scrollup() {
|
||||||
|
// this tests makes sure that when we have a git diff that exceeds the screen size
|
||||||
|
// we are able to scroll up
|
||||||
|
let fake_win_size = PositionAndSize {
|
||||||
|
columns: 149,
|
||||||
|
rows: 28,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
};
|
||||||
|
let fixture_name = "git_diff_scrollup";
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
source: src/tests/integration/compatibility.rs
|
||||||
|
expression: snapshot
|
||||||
|
---
|
||||||
|
|
||||||
|
* wip: doesn't render when new tab is created?
|
||||||
|
|
||||||
|
* wip: doesnt re-render when a new tab is spawned for now
|
||||||
|
|
||||||
|
* wip: tabs now are a BTreeMap and we can switch between them in both directions
|
||||||
|
|
||||||
|
* wip: I think that should also be here
|
||||||
|
|
||||||
|
* wip: cleanup
|
||||||
|
|
||||||
|
* Spawn a new terminal simultaneously with a new tab
|
||||||
|
|
||||||
|
* Ensure proper Opening and Closing of tabs
|
||||||
|
|
||||||
|
* cleanup
|
||||||
|
|
||||||
|
* more cleanup
|
||||||
|
|
||||||
|
* tests(snapshots): add 'loading' snapshot to each scenario
|
||||||
|
|
||||||
|
* fix(tests): update snapshots
|
||||||
|
|
||||||
|
* Add tests for tabs implementation
|
||||||
|
|
||||||
|
* wip: added tests, moved tab related stuff to a separate file
|
||||||
|
|
||||||
|
:█
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
source: src/tests/integration/compatibility.rs
|
||||||
|
expression: snapshot
|
||||||
|
---
|
||||||
|
* wip: doesn't render when new tab is created?
|
||||||
|
|
||||||
|
* wip: doesnt re-render when a new tab is spawned for now
|
||||||
|
|
||||||
|
* wip: tabs now are a BTreeMap and we can switch between them in both directions
|
||||||
|
|
||||||
|
* wip: I think that should also be here
|
||||||
|
|
||||||
|
* wip: cleanup
|
||||||
|
|
||||||
|
* Spawn a new terminal simultaneously with a new tab
|
||||||
|
|
||||||
|
* Ensure proper Opening and Closing of tabs
|
||||||
|
|
||||||
|
* cleanup
|
||||||
|
|
||||||
|
* more cleanup
|
||||||
|
|
||||||
|
* tests(snapshots): add 'loading' snapshot to each scenario
|
||||||
|
|
||||||
|
* fix(tests): update snapshots
|
||||||
|
|
||||||
|
* Add tests for tabs implementation
|
||||||
|
|
||||||
|
* wip: added tests, moved tab related stuff to a separate file
|
||||||
|
|
||||||
|
:
|
||||||
|
Bye from Mosaic!█
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
source: src/tests/integration/compatibility.rs
|
||||||
|
expression: snapshot
|
||||||
|
---
|
||||||
|
█
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
source: src/tests/integration/compatibility.rs
|
||||||
|
expression: snapshot
|
||||||
|
---
|
||||||
|
|
||||||
|
src/terminal_pane/scroll.rs
|
||||||
|
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
────────────────────────────────────────────────┐
|
||||||
|
use crate::terminal_pane::terminal_character::{ │
|
||||||
|
────────────────────────────────────────────────┘
|
||||||
|
5
|
||||||
|
CharacterStyles, TerminalCharacter, EMPTY_TERMINAL_CHARACTER,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::utils::logging::debug_log_to_file;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Scroll
|
||||||
|
*
|
||||||
|
|
||||||
|
──────────────┐
|
||||||
|
impl Scroll { │
|
||||||
|
──────────────┘
|
||||||
|
663
|
||||||
|
pub fn move_current_buffer_to_alternative_buffer(&mut self) {
|
||||||
|
self.alternative_buffer = Some(self.canonical_lines.drain(..).collect());
|
||||||
|
self.alternative_cursor_position = Some(self.cursor_position);
|
||||||
|
self.cursor_position.reset();
|
||||||
|
self.clear_all();
|
||||||
|
}
|
||||||
|
:█
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
source: src/tests/integration/compatibility.rs
|
||||||
|
expression: snapshot
|
||||||
|
---
|
||||||
|
src/terminal_pane/scroll.rs
|
||||||
|
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
────────────────────────────────────────────────┐
|
||||||
|
use crate::terminal_pane::terminal_character::{ │
|
||||||
|
────────────────────────────────────────────────┘
|
||||||
|
5
|
||||||
|
CharacterStyles, TerminalCharacter, EMPTY_TERMINAL_CHARACTER,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::utils::logging::debug_log_to_file;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Scroll
|
||||||
|
*
|
||||||
|
|
||||||
|
──────────────┐
|
||||||
|
impl Scroll { │
|
||||||
|
──────────────┘
|
||||||
|
663
|
||||||
|
pub fn move_current_buffer_to_alternative_buffer(&mut self) {
|
||||||
|
self.alternative_buffer = Some(self.canonical_lines.drain(..).collect());
|
||||||
|
self.alternative_cursor_position = Some(self.cursor_position);
|
||||||
|
self.cursor_position.reset();
|
||||||
|
self.clear_all();
|
||||||
|
}
|
||||||
|
:
|
||||||
|
Bye from Mosaic!█
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
source: src/tests/integration/compatibility.rs
|
||||||
|
expression: snapshot
|
||||||
|
---
|
||||||
|
█
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
source: src/tests/integration/compatibility.rs
|
||||||
|
expression: snapshot
|
||||||
|
---
|
||||||
|
|
||||||
|
* wip: doesn't render when new tab is created?
|
||||||
|
|
||||||
|
* wip: doesnt re-render when a new tab is spawned for now
|
||||||
|
|
||||||
|
* wip: tabs now are a BTreeMap and we can switch between them in both directions
|
||||||
|
|
||||||
|
* wip: I think that should also be here
|
||||||
|
|
||||||
|
* wip: cleanup
|
||||||
|
|
||||||
|
* Spawn a new terminal simultaneously with a new tab
|
||||||
|
|
||||||
|
* Ensure proper Opening and Closing of tabs
|
||||||
|
|
||||||
|
* cleanup
|
||||||
|
|
||||||
|
* more cleanup
|
||||||
|
|
||||||
|
* tests(snapshots): add 'loading' snapshot to each scenario
|
||||||
|
|
||||||
|
* fix(tests): update snapshots
|
||||||
|
|
||||||
|
* Add tests for tabs implementation
|
||||||
|
|
||||||
|
* wip: added tests, moved tab related stuff to a separate file
|
||||||
|
|
||||||
|
:█
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
source: src/tests/integration/compatibility.rs
|
||||||
|
expression: snapshot
|
||||||
|
---
|
||||||
|
* wip: doesn't render when new tab is created?
|
||||||
|
|
||||||
|
* wip: doesnt re-render when a new tab is spawned for now
|
||||||
|
|
||||||
|
* wip: tabs now are a BTreeMap and we can switch between them in both directions
|
||||||
|
|
||||||
|
* wip: I think that should also be here
|
||||||
|
|
||||||
|
* wip: cleanup
|
||||||
|
|
||||||
|
* Spawn a new terminal simultaneously with a new tab
|
||||||
|
|
||||||
|
* Ensure proper Opening and Closing of tabs
|
||||||
|
|
||||||
|
* cleanup
|
||||||
|
|
||||||
|
* more cleanup
|
||||||
|
|
||||||
|
* tests(snapshots): add 'loading' snapshot to each scenario
|
||||||
|
|
||||||
|
* fix(tests): update snapshots
|
||||||
|
|
||||||
|
* Add tests for tabs implementation
|
||||||
|
|
||||||
|
* wip: added tests, moved tab related stuff to a separate file
|
||||||
|
|
||||||
|
:
|
||||||
|
Bye from Mosaic!█
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
source: src/tests/integration/compatibility.rs
|
||||||
|
expression: snapshot
|
||||||
|
---
|
||||||
|
█
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue