From a1febb52bd2ac5cec0902e2e060c2cafeaf9afa8 Mon Sep 17 00:00:00 2001 From: denis Date: Tue, 5 Jan 2021 11:52:12 +0200 Subject: [PATCH 1/3] fix: fixes #130 by adding overflowing_sub --- src/terminal_pane/scroll.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/terminal_pane/scroll.rs b/src/terminal_pane/scroll.rs index 6301c7c1..0c94a0d8 100644 --- a/src/terminal_pane/scroll.rs +++ b/src/terminal_pane/scroll.rs @@ -1,4 +1,4 @@ -use std::collections::VecDeque; +use std::{collections::VecDeque}; use std::fmt::{self, Debug, Formatter}; use crate::terminal_pane::terminal_character::{ @@ -266,7 +266,7 @@ impl CursorPosition { self.column_index += count; } pub fn move_backwards(&mut self, count: usize) { - self.column_index -= count; + self.column_index = u32::overflowing_sub(self.column_index as u32, count as u32).0 as usize; } pub fn move_to_next_linewrap(&mut self) { self.line_index.1 += 1; From 7c41c5f624e1ce19be99d8c09b0971dd9527fc9b Mon Sep 17 00:00:00 2001 From: denis Date: Tue, 5 Jan 2021 11:54:36 +0200 Subject: [PATCH 2/3] chore: fmt --- src/terminal_pane/scroll.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/terminal_pane/scroll.rs b/src/terminal_pane/scroll.rs index 0c94a0d8..0bf4c731 100644 --- a/src/terminal_pane/scroll.rs +++ b/src/terminal_pane/scroll.rs @@ -1,4 +1,4 @@ -use std::{collections::VecDeque}; +use std::collections::VecDeque; use std::fmt::{self, Debug, Formatter}; use crate::terminal_pane::terminal_character::{ From cde7703ac79d06c8def65401fef0da6912b5977b Mon Sep 17 00:00:00 2001 From: denis Date: Wed, 6 Jan 2021 10:08:47 +0200 Subject: [PATCH 3/3] wip: added a test --- src/tests/fixtures/emacs_longbuf_tutorial | Bin 0 -> 9781 bytes src/tests/integration/compatibility.rs | 23 +++++++ ...ation__compatibility__emacs_longbuf-2.snap | 64 ++++++++++++++++++ ...ation__compatibility__emacs_longbuf-3.snap | 64 ++++++++++++++++++ ...gration__compatibility__emacs_longbuf.snap | 64 ++++++++++++++++++ 5 files changed, 215 insertions(+) create mode 100644 src/tests/fixtures/emacs_longbuf_tutorial create mode 100644 src/tests/integration/snapshots/mosaic__tests__integration__compatibility__emacs_longbuf-2.snap create mode 100644 src/tests/integration/snapshots/mosaic__tests__integration__compatibility__emacs_longbuf-3.snap create mode 100644 src/tests/integration/snapshots/mosaic__tests__integration__compatibility__emacs_longbuf.snap diff --git a/src/tests/fixtures/emacs_longbuf_tutorial b/src/tests/fixtures/emacs_longbuf_tutorial new file mode 100644 index 0000000000000000000000000000000000000000..f383e6d15b23324008541703b72dac6dd658e0e8 GIT binary patch literal 9781 zcmeHN+iu&)8P;950`vsF`I{nG+tpdJ6I-dbj$+4ddhn`u#Jc4z^?`MJ|#>1lW?ung4wF{-IVb8qvzdlj!lvMe_+h@wa+Jzrk0D zN-IA%JHCtq{g?XnVEdo77s^W`85>>mlpn;GH8qm)FIuIECu@M?9@AT!*S8Kku9okQ#%K7>Eb_K8fhD`%Y(#2!GWLm7%q2wd$)_TF)MU(Gm`wRtsUk zOg8EwHOf=*;1-z&No+jLNH~V~a@)w3dXe}bE50z|bGdESKcAZ)cqUM>NCK%Vo+U?F(&ePht66lc(LzwtM+vFQ-S0br-!W+uk0%4p}Wt}H;kTAVDK z&B(<@B;r&6IZgp!rWKP+at#q|GdrIrYOE!>t@_Sh-We=qXn=r{U;#_sW^#t-v9HJ* ziuh9Mi9pwsE+G3ny;&*>wldkXy`Ceoca2`)6wf(zE7w?qK6J-GyXXm5!az|Or+ty! zQuMg;H@j)|$q&F)2*L*=Bw4LEcn}u;O^ZieqU6ts;4ML$gM_)Dk=# z(2YuID6S;MitH-fEZeJ*xIwNXhXrz)b9nDfmj)^f)mZw}zp<=gIPPdNsXE7>YdJ_m zGD3gQ+Y2;(8vyIli5wGm%v*ZqhRWXOL*W#YIvsFuzX%fP!L>KD+ZXWarrM||_=lu7 z46W1A?D~g!O*=u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r-9N%#z~+3HGoReTZ^n<#%j}-nlX)=^57TOzKXy$twA(c!*Om zq&`Y=tPD(p0>Kf;7I%TB0VV7-JwXmQ!h!!+dt-ZScg4__v} z*Ys#-=TW{Ul&H0lNKj*8P&_f=<0aRoc^bCnaP7WSGyqzuwjs%NlLdu_vxqB;PDc55 zu(ki}x8lWd;QI(iG=~u|7g@$=L-7a8!w-CZ;^EOKO-2gV1ZC>UYrrNIqj982OC+Tl z|LhWAN;w}XCRcWL=tPZk3trLc+W@UHW?FzjQpRiSK77O(l{=iwP*HALRFHNZmDL60 z>Lmc@5V(wcD3A;{E6xnIgAHaj^=u)T3+}5m*#GzY+#+KL#pf+Rv>c=$h8B$z7PwBL zo!Mdy{KxeG6gj+LEB@%Dc9Cd{_2%7T4WRJ_$CDm{%|2zHmg*&QZayOOPYL)b0RM_0 q`zgv?O<(qtg6}^_`Rad=a$N`t27b={YTcaw#0ZGi{Q`wQ6#fT%mM6mi literal 0 HcmV?d00001 diff --git a/src/tests/integration/compatibility.rs b/src/tests/integration/compatibility.rs index e42a26fb..e9b379ab 100644 --- a/src/tests/integration/compatibility.rs +++ b/src/tests/integration/compatibility.rs @@ -461,3 +461,26 @@ pub fn git_diff_scrollup() { assert_snapshot!(snapshot); } } + +#[test] +pub fn emacs_longbuf() { + let fake_win_size = PositionAndSize { + columns: 284, + rows: 60, + x: 0, + y: 0, + }; + let fixture_name = "emacs_longbuf_tutorial"; + 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__emacs_longbuf-2.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__emacs_longbuf-2.snap new file mode 100644 index 00000000..6ab342a0 --- /dev/null +++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__emacs_longbuf-2.snap @@ -0,0 +1,64 @@ +--- +source: src/tests/integration/compatibility.rs +expression: snapshot +--- +➜ mosaic git:(mosaic#130) emacs +➜ mosaic git:(mosaic#130) emacs -nw +➜ mosaic git:(mosaic#130) exit +█ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__emacs_longbuf-3.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__emacs_longbuf-3.snap new file mode 100644 index 00000000..644e2213 --- /dev/null +++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__emacs_longbuf-3.snap @@ -0,0 +1,64 @@ +--- +source: src/tests/integration/compatibility.rs +expression: snapshot +--- +➜ mosaic git:(mosaic#130) emacs -nw +➜ mosaic git:(mosaic#130) exit + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Bye from Mosaic!█ diff --git a/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__emacs_longbuf.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__emacs_longbuf.snap new file mode 100644 index 00000000..8741ce12 --- /dev/null +++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__emacs_longbuf.snap @@ -0,0 +1,64 @@ +--- +source: src/tests/integration/compatibility.rs +expression: snapshot +--- +█ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +