This commit is contained in:
Kovid Goyal 2021-04-09 16:56:53 +05:30
parent 0be5347e6a
commit cf3662442f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 4 additions and 18 deletions

View File

@ -326,15 +326,6 @@ is_continued(LineBuf *self, PyObject *val) {
Py_RETURN_FALSE;
}
unsigned int
linebuf_continued_lines_count(const LineBuf *self, const index_type stop_before_line) {
index_type count = 0;
for (index_type i = 0; i < self->ynum && i < stop_before_line; i++) {
if (self->line_attrs[i] & CONTINUED_MASK) count++;
}
return count;
}
void
linebuf_insert_lines(LineBuf *self, unsigned int num, unsigned int y, unsigned int bottom) {
index_type i;

View File

@ -91,7 +91,6 @@ void linebuf_clear(LineBuf *, char_type ch);
void linebuf_index(LineBuf* self, index_type top, index_type bottom);
void linebuf_reverse_index(LineBuf *self, index_type top, index_type bottom);
void linebuf_clear_line(LineBuf *self, index_type y);
unsigned int linebuf_continued_lines_count(const LineBuf *, const index_type);
void linebuf_insert_lines(LineBuf *self, unsigned int num, unsigned int y, unsigned int bottom);
void linebuf_delete_lines(LineBuf *self, index_type num, index_type y, index_type bottom);
void linebuf_copy_line_to(LineBuf *, Line *, index_type);

View File

@ -273,6 +273,7 @@ screen_resize(Screen *self, unsigned int lines, unsigned int columns) {
index_type num_content_lines_before, num_content_lines_after, num_content_lines;
unsigned int cursor_x = 0, cursor_y = 0;
bool cursor_is_beyond_content = false;
unsigned int lines_after_cursor_before_resize = self->lines - self->cursor->y;
#define setup_cursor() { \
cursor_x = x; cursor_y = y; \
cursor_is_beyond_content = num_content_lines_before > 0 && self->cursor->y >= num_content_lines_before; \
@ -290,10 +291,6 @@ screen_resize(Screen *self, unsigned int lines, unsigned int columns) {
if (n == NULL) return false;
int lines_to_fill = -1;
if (is_main && OPT(scrollback_fill_enlarged_window)) {
lines_to_fill = (lines - self->main_linebuf->ynum) + linebuf_continued_lines_count(self->main_linebuf, self->cursor->y + 1);
}
Py_CLEAR(self->main_linebuf); self->main_linebuf = n;
if (is_main) setup_cursor();
grman_resize(self->main_grman, self->lines, lines, self->columns, columns);
@ -329,14 +326,13 @@ screen_resize(Screen *self, unsigned int lines, unsigned int columns) {
self->cursor->y = num_content_lines;
if (self->cursor->y >= self->lines) { self->cursor->y = self->lines - 1; screen_index(self); }
}
if (lines_to_fill > 0) {
lines_to_fill -= linebuf_continued_lines_count(self->main_linebuf, self->cursor->y + 1);
if (is_main && OPT(scrollback_fill_enlarged_window)) {
const unsigned int top = 0, bottom = self->lines-1;
while (lines_to_fill-- > 0) {
while (self->cursor->y + 1 < self->lines && self->lines - self->cursor->y > lines_after_cursor_before_resize) {
if (!historybuf_pop_line(self->historybuf, self->alt_linebuf->line)) break;
INDEX_DOWN;
linebuf_copy_line_to(self->main_linebuf, self->alt_linebuf->line, 0);
if (self->cursor->y + 1 < self->lines) self->cursor->y++;
self->cursor->y++;
}
}
return true;