mirror of
https://github.com/neovim/neovim.git
synced 2025-01-01 17:23:36 -07:00
vim-patch:8.2.1995: the popup menu can cause too much redrawing
Problem: The popup menu can cause too much redrawing.
Solution: Reduce the length of the displayed text. (Yasuhiro Matsumoto,
closes vim/vim#7306)
714cbe5b21
This commit is contained in:
parent
ce70edb80e
commit
b98348258d
@ -376,6 +376,8 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
|
|||||||
// the positioning. Limit this to two times, when there is not much
|
// the positioning. Limit this to two times, when there is not much
|
||||||
// room the window size will keep changing.
|
// room the window size will keep changing.
|
||||||
} while (pum_set_selected(selected, redo_count) && (++redo_count <= 2));
|
} while (pum_set_selected(selected, redo_count) && (++redo_count <= 2));
|
||||||
|
|
||||||
|
pum_redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Redraw the popup menu, using "pum_first" and "pum_selected".
|
/// Redraw the popup menu, using "pum_first" and "pum_selected".
|
||||||
@ -534,7 +536,17 @@ void pum_redraw(void)
|
|||||||
xfree(st);
|
xfree(st);
|
||||||
col -= width;
|
col -= width;
|
||||||
} else {
|
} else {
|
||||||
grid_puts_len(&pum_grid, st, (int)STRLEN(st), row, col, attr);
|
int size = (int)STRLEN(st);
|
||||||
|
int cells = (int)mb_string2cells(st);
|
||||||
|
|
||||||
|
// only draw the text that fits
|
||||||
|
while (size > 0 && col + cells > pum_width + pum_col) {
|
||||||
|
size--;
|
||||||
|
size -= utf_head_off(st, st + size);
|
||||||
|
cells -= utf_ptr2cells(st + size);
|
||||||
|
}
|
||||||
|
|
||||||
|
grid_puts_len(&pum_grid, st, size, row, col, attr);
|
||||||
xfree(st);
|
xfree(st);
|
||||||
col += width;
|
col += width;
|
||||||
}
|
}
|
||||||
@ -824,10 +836,6 @@ static int pum_set_selected(int n, int repeat)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resized) {
|
|
||||||
pum_redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
return resized;
|
return resized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user