Fix whitespace overflow in copy_area_with_break
parent
1389c4b1d5
commit
1fd43eb671
|
@ -145,9 +145,6 @@ impl Component for MailView {
|
|||
for c in c_slice[i..i+3].iter_mut() {
|
||||
c.set_fg(Color::Byte(226));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
|
|
|
@ -96,6 +96,15 @@ pub fn copy_area_with_break(grid_dest: &mut CellBuffer, grid_src: &CellBuffer, d
|
|||
|
||||
'y_: for y in get_y(upper_left!(dest))..=get_y(bottom_right!(dest)) {
|
||||
'x_: for x in get_x(upper_left!(dest))..=get_x(bottom_right!(dest)) {
|
||||
if grid_src[(src_x, src_y)].ch() == '\n' {
|
||||
src_y += 1;
|
||||
src_x = 0;
|
||||
if src_y == get_y(bottom_right!(src)) {
|
||||
break 'y_;
|
||||
}
|
||||
continue 'y_;
|
||||
}
|
||||
|
||||
grid_dest[(x,y)] = grid_src[(src_x, src_y)];
|
||||
if src_x == get_x(bottom_right!(src)) {
|
||||
src_y += 1;
|
||||
|
|
|
@ -195,16 +195,17 @@ impl Pager {
|
|||
pub fn from_buf(buf: CellBuffer) -> Self {
|
||||
let lines: Vec<&[Cell]> = buf.split(|cell| cell.ch() == '\n').collect();
|
||||
let height = lines.len();
|
||||
let width = lines.iter().map(|l| l.len()).max().unwrap_or(0);
|
||||
let width = lines.iter().map(|l| l.len()).max().unwrap_or(0) + 1;
|
||||
let mut content = CellBuffer::new(width, height, Cell::with_char(' '));
|
||||
{
|
||||
let mut x = 0;
|
||||
let mut x;
|
||||
let mut y = 0;
|
||||
let c_slice: &mut [Cell] = &mut content;
|
||||
for l in lines {
|
||||
let y_r = y * width;
|
||||
x = l.len() + y_r;
|
||||
c_slice[y_r..x].copy_from_slice(l);
|
||||
c_slice[x].set_ch('\n');
|
||||
y += 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue