Better fix for reflow with last line being empty output start line
This commit is contained in:
parent
2487f55bbc
commit
101377d7f2
@ -581,16 +581,13 @@ linebuf_rewrap(LineBuf *self, LineBuf *other, index_type *num_content_lines_befo
|
||||
*num_content_lines_before = 0;
|
||||
return;
|
||||
}
|
||||
bool first_empty_line_is_output_start = first + 1 < self->ynum && self->line_attrs[first + 1].is_output_start;
|
||||
|
||||
*num_content_lines_before = first + 1;
|
||||
TrackCursor tcarr[3] = {{.x = *track_x, .y = *track_y }, {.x = *track_x2, .y = *track_y2}, {.is_sentinel = true}};
|
||||
rewrap_inner(self, other, first + 1, historybuf, (TrackCursor*)tcarr, as_ansi_buf);
|
||||
rewrap_inner(self, other, *num_content_lines_before, historybuf, (TrackCursor*)tcarr, as_ansi_buf);
|
||||
*track_x = tcarr[0].x; *track_y = tcarr[0].y;
|
||||
*track_x2 = tcarr[1].x; *track_y2 = tcarr[1].y;
|
||||
*num_content_lines_after = other->line->ynum + 1;
|
||||
for (i = 0; i < *num_content_lines_after; i++) other->line_attrs[i].has_dirty_text = true;
|
||||
*num_content_lines_before = first + 1;
|
||||
if (first_empty_line_is_output_start && other->line->ynum + 1 < other->ynum) other->line_attrs[other->line->ynum + 1].is_output_start = true;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
|
||||
@ -315,6 +315,16 @@ screen_resize(Screen *self, unsigned int lines, unsigned int columns) {
|
||||
|
||||
bool is_main = self->linebuf == self->main_linebuf;
|
||||
index_type num_content_lines_before, num_content_lines_after;
|
||||
bool dummy_output_inserted = false;
|
||||
if (is_main && self->cursor->x == 0 && self->cursor->y < self->lines && self->linebuf->line_attrs[self->cursor->y].is_output_start) {
|
||||
linebuf_init_line(self->linebuf, self->cursor->y);
|
||||
if (!self->linebuf->line->cpu_cells[0].ch) {
|
||||
// we have a blank output start line, we need it to be preserved by
|
||||
// reflow, so insert a dummy char
|
||||
self->linebuf->line->cpu_cells[self->cursor->x++].ch = '<';
|
||||
dummy_output_inserted = true;
|
||||
}
|
||||
}
|
||||
unsigned int lines_after_cursor_before_resize = self->lines - self->cursor->y;
|
||||
CursorTrack cursor = {.before = {self->cursor->x, self->cursor->y}};
|
||||
CursorTrack main_saved_cursor = {.before = {self->main_savepoint.cursor.x, self->main_savepoint.cursor.y}};
|
||||
@ -384,6 +394,11 @@ screen_resize(Screen *self, unsigned int lines, unsigned int columns) {
|
||||
sp->cursor.y = MIN(sp->cursor.y + 1, self->lines - 1);
|
||||
}
|
||||
}
|
||||
if (dummy_output_inserted && self->cursor->y < self->lines) {
|
||||
linebuf_init_line(self->linebuf, self->cursor->y);
|
||||
self->linebuf->line->cpu_cells[0].ch = 0;
|
||||
self->cursor->x = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user