mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-27 19:21:52 +03:00
fix(compatibility): fish multiline paste (#112)
* fix(compatibility): fix fish multiline paste * fix(tests): adjust snapshots of test to tabs * style(formatting): make rustfmt happy
This commit is contained in:
parent
51607c655c
commit
83a830e4ab
@ -284,14 +284,6 @@ impl CursorPosition {
|
||||
self.column_index = 0;
|
||||
self.line_index.1 = 0;
|
||||
}
|
||||
pub fn move_up_by_canonical_lines(&mut self, count: usize) {
|
||||
let current_canonical_line_position = self.line_index.0;
|
||||
if count > current_canonical_line_position {
|
||||
self.line_index = (0, 0);
|
||||
} else {
|
||||
self.line_index = (current_canonical_line_position - count, 0);
|
||||
}
|
||||
}
|
||||
pub fn move_down_by_canonical_lines(&mut self, count: usize) {
|
||||
// this method does not verify that we will not overflow
|
||||
let current_canonical_line_position = self.line_index.0;
|
||||
@ -508,7 +500,24 @@ impl Scroll {
|
||||
self.cursor_position.move_backwards(count);
|
||||
}
|
||||
pub fn move_cursor_up(&mut self, count: usize) {
|
||||
self.cursor_position.move_up_by_canonical_lines(count);
|
||||
for _ in 0..count {
|
||||
let (current_canonical_line_index, current_line_wrap_index) =
|
||||
self.cursor_position.line_index;
|
||||
if current_line_wrap_index > 0 {
|
||||
// go up one line-wrap
|
||||
self.cursor_position.line_index.1 -= 1;
|
||||
} else if current_canonical_line_index > 0 {
|
||||
// go up to previous canonical line
|
||||
self.cursor_position.line_index.0 -= 1;
|
||||
let current_canonical_line = self
|
||||
.canonical_lines
|
||||
.get(self.cursor_position.line_index.0)
|
||||
.unwrap();
|
||||
let wraps_in_current_line = current_canonical_line.wrapped_fragments.len();
|
||||
// make sure to only go up to the last wrap of the previous line
|
||||
self.cursor_position.line_index.1 = wraps_in_current_line - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn move_cursor_down(&mut self, count: usize) {
|
||||
let current_canonical_line = self.cursor_position.line_index.0;
|
||||
|
BIN
src/tests/fixtures/fish_paste_multiline
vendored
Normal file
BIN
src/tests/fixtures/fish_paste_multiline
vendored
Normal file
Binary file not shown.
@ -388,3 +388,28 @@ pub fn bash_cursor_linewrap() {
|
||||
assert_snapshot!(snapshot);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn fish_paste_multiline() {
|
||||
// here we paste a multiline command in fish shell, making sure we support it
|
||||
// going up and changing the colors of our line-wrapped pasted text
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 149,
|
||||
rows: 28,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let fixture_name = "fish_paste_multiline";
|
||||
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
|
||||
---
|
||||
|
||||
OS: 5.9.14-arch1-1 GNU/Linux
|
||||
Uptime: 12 hours, 21 minutes
|
||||
Hostname: kingdom
|
||||
Disk usage:
|
||||
|
||||
df: /run/user/1000/doc: Operation not permitted
|
||||
/ 295G / 514G 61%
|
||||
/efi 27M / 96M 28%
|
||||
|
||||
Network:
|
||||
|
||||
wlp2s0 192.168.0.3
|
||||
|
||||
[I] [21:58] kingdom:mosaic (main) | echo -ne (\
|
||||
df -l -h | grep -E 'dev/(xvda|sd|mapper)' | \
|
||||
awk '{printf "\\\\t%s\\\\t%4s / %4s %s\\\\n\n", $6, $3, $2, $5}' | \
|
||||
sed -e 's/^\(.*\([8][5-9]\|[9][0-9]\)%.*\)$/\\\\e[0;31m\1\\\\e[0m/' -e 's/^\(.*\([7][5-9]\|[8][0-4]\)%.*\
|
||||
)$/\\\\e[0;33m\1\\\\e[0m/' | \
|
||||
)
|
||||
paste -sd ''\
|
||||
)█
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
---
|
||||
source: src/tests/integration/compatibility.rs
|
||||
expression: snapshot
|
||||
---
|
||||
OS: 5.9.14-arch1-1 GNU/Linux
|
||||
Uptime: 12 hours, 21 minutes
|
||||
Hostname: kingdom
|
||||
Disk usage:
|
||||
|
||||
df: /run/user/1000/doc: Operation not permitted
|
||||
/ 295G / 514G 61%
|
||||
/efi 27M / 96M 28%
|
||||
|
||||
Network:
|
||||
|
||||
wlp2s0 192.168.0.3
|
||||
|
||||
[I] [21:58] kingdom:mosaic (main) | echo -ne (\
|
||||
df -l -h | grep -E 'dev/(xvda|sd|mapper)' | \
|
||||
awk '{printf "\\\\t%s\\\\t%4s / %4s %s\\\\n\n", $6, $3, $2, $5}' | \
|
||||
sed -e 's/^\(.*\([8][5-9]\|[9][0-9]\)%.*\)$/\\\\e[0;31m\1\\\\e[0m/' -e 's/^\(.*\([7][5-9]\|[8][0-4]\)%.*\
|
||||
)$/\\\\e[0;33m\1\\\\e[0m/' | \
|
||||
)
|
||||
paste -sd ''\
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Bye from Mosaic!█
|
@ -0,0 +1,32 @@
|
||||
---
|
||||
source: src/tests/integration/compatibility.rs
|
||||
expression: snapshot
|
||||
---
|
||||
█
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user