mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
multigrid: Fix grid allocation misses
- Clear whole grid in one go. - Fix wrongly sent "copy" flag. - Add clear function comment.
This commit is contained in:

committed by
Björn Linse

parent
1a896bc93f
commit
882dd63dc7
@@ -679,7 +679,7 @@ static void win_update(win_T *wp)
|
|||||||
|
|
||||||
type = wp->w_redr_type;
|
type = wp->w_redr_type;
|
||||||
|
|
||||||
win_grid_alloc(wp, false);
|
win_grid_alloc(wp, true);
|
||||||
|
|
||||||
if (type >= NOT_VALID) {
|
if (type >= NOT_VALID) {
|
||||||
wp->w_redr_status = true;
|
wp->w_redr_status = true;
|
||||||
@@ -5966,9 +5966,11 @@ int screen_valid(int doclear)
|
|||||||
return default_grid.ScreenLines != NULL;
|
return default_grid.ScreenLines != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// (re)allocate a window grid if size changed
|
/// (Re)allocates a window grid if size changed while in ext_multigrid mode.
|
||||||
/// If "doclear" is true, clear the screen if resized.
|
/// Updates size, offsets and handle for the grid regardless.
|
||||||
// TODO(utkarshme): Think of a better name, place
|
///
|
||||||
|
/// If "doclear" is true, don't try to copy from the old grid rather clear the
|
||||||
|
/// resized grid.
|
||||||
void win_grid_alloc(win_T *wp, int doclear)
|
void win_grid_alloc(win_T *wp, int doclear)
|
||||||
{
|
{
|
||||||
ScreenGrid *grid = &wp->w_grid;
|
ScreenGrid *grid = &wp->w_grid;
|
||||||
@@ -6151,15 +6153,14 @@ void grid_alloc(ScreenGrid *grid, int rows, int columns, bool copy)
|
|||||||
for (new_row = 0; new_row < new.Rows; new_row++) {
|
for (new_row = 0; new_row < new.Rows; new_row++) {
|
||||||
new.LineOffset[new_row] = new_row * new.Columns;
|
new.LineOffset[new_row] = new_row * new.Columns;
|
||||||
new.LineWraps[new_row] = false;
|
new.LineWraps[new_row] = false;
|
||||||
|
|
||||||
|
grid_clear_line(&new, 0, columns);
|
||||||
|
|
||||||
if (copy) {
|
if (copy) {
|
||||||
// If the screen is not going to be cleared, copy as much as
|
// If the screen is not going to be cleared, copy as much as
|
||||||
// possible from the old screen to the new one and clear the rest
|
// possible from the old screen to the new one and clear the rest
|
||||||
// (used when resizing the window at the "--more--" prompt or when
|
// (used when resizing the window at the "--more--" prompt or when
|
||||||
// executing an external command, for the GUI).
|
// executing an external command, for the GUI).
|
||||||
memset(new.ScreenLines + new_row * new.Columns,
|
|
||||||
' ', (size_t)new.Columns * sizeof(schar_T));
|
|
||||||
memset(new.ScreenAttrs + new_row * new.Columns,
|
|
||||||
0, (size_t)new.Columns * sizeof(sattr_T));
|
|
||||||
old_row = new_row + (grid->Rows - new.Rows);
|
old_row = new_row + (grid->Rows - new.Rows);
|
||||||
if (old_row >= 0 && grid->ScreenLines != NULL) {
|
if (old_row >= 0 && grid->ScreenLines != NULL) {
|
||||||
int len = MIN(grid->Columns, new.Columns);
|
int len = MIN(grid->Columns, new.Columns);
|
||||||
|
Reference in New Issue
Block a user