mirror of
https://github.com/zellij-org/zellij.git
synced 2024-11-27 06:25:42 +03:00
fix(compatibility): handle deleting chars in lines with widechars (#965)
* fix(compatibility): handle deleting chars in lines with widechars * style(fmt): make rustfmt happy
This commit is contained in:
parent
827db866e7
commit
ec4649c7c9
1
src/tests/fixtures/wide-chars-delete-middle
vendored
Executable file
1
src/tests/fixtures/wide-chars-delete-middle
vendored
Executable file
@ -0,0 +1 @@
|
||||
[?2004h[aram@green zellij]$
[K[aram@green zellij]$ [7m🏠[27m🏠 abc5~[K[Kdabceabcfabc abc[1@x[1P
|
1
src/tests/fixtures/wide-chars-delete-middle-after-multi
vendored
Executable file
1
src/tests/fixtures/wide-chars-delete-middle-after-multi
vendored
Executable file
@ -0,0 +1 @@
|
||||
[?2004h[aram@green zellij]$
[K[aram@green zellij]$ [7m🏠[27m🏠[7m🏠[27m🏠[7m🏠[27m🏠a🏠[1P🏠
|
@ -2249,8 +2249,7 @@ impl Row {
|
||||
}
|
||||
}
|
||||
pub fn insert_character_at(&mut self, terminal_character: TerminalCharacter, x: usize) {
|
||||
let width_offset = self.excess_width_until(x);
|
||||
let insert_position = x.saturating_sub(width_offset);
|
||||
let insert_position = self.absolute_character_index(x);
|
||||
match self.columns.len().cmp(&insert_position) {
|
||||
Ordering::Equal => self.columns.push_back(terminal_character),
|
||||
Ordering::Less => {
|
||||
@ -2368,8 +2367,9 @@ impl Row {
|
||||
self.columns.is_empty()
|
||||
}
|
||||
pub fn delete_and_return_character(&mut self, x: usize) -> Option<TerminalCharacter> {
|
||||
if x < self.columns.len() {
|
||||
Some(self.columns.remove(x).unwrap()) // TODO: just return the remove part?
|
||||
let erase_position = self.absolute_character_index(x);
|
||||
if erase_position < self.columns.len() {
|
||||
Some(self.columns.remove(erase_position).unwrap()) // TODO: just return the remove part?
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -432,6 +432,30 @@ fn insert_character_in_line_with_wide_character() {
|
||||
assert_snapshot!(format!("{:?}", grid));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn delete_char_in_middle_of_line_with_widechar() {
|
||||
let mut vte_parser = vte::Parser::new();
|
||||
let mut grid = Grid::new(21, 104, Palette::default());
|
||||
let fixture_name = "wide-chars-delete-middle";
|
||||
let content = read_fixture(fixture_name);
|
||||
for byte in content {
|
||||
vte_parser.advance(&mut grid, byte);
|
||||
}
|
||||
assert_snapshot!(format!("{:?}", grid));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn delete_char_in_middle_of_line_with_multiple_widechars() {
|
||||
let mut vte_parser = vte::Parser::new();
|
||||
let mut grid = Grid::new(21, 104, Palette::default());
|
||||
let fixture_name = "wide-chars-delete-middle-after-multi";
|
||||
let content = read_fixture(fixture_name);
|
||||
for byte in content {
|
||||
vte_parser.advance(&mut grid, byte);
|
||||
}
|
||||
assert_snapshot!(format!("{:?}", grid));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fish_wide_characters_override_clock() {
|
||||
let mut vte_parser = vte::Parser::new();
|
||||
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
source: zellij-server/src/panes/./unit/grid_tests.rs
|
||||
expression: "format!(\"{:?}\", grid)"
|
||||
|
||||
---
|
||||
00 (C): [aram@green zellij]$ 🏠🏠🏠
|
||||
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
source: zellij-server/src/panes/./unit/grid_tests.rs
|
||||
expression: "format!(\"{:?}\", grid)"
|
||||
|
||||
---
|
||||
00 (C): [aram@green zellij]$ 🏠 def abc
|
||||
|
Loading…
Reference in New Issue
Block a user