mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:9.1.1306: completion menu rendering can be improved
Problem: Parts of the popup menu were rendered twice when the popup was
at maximum width because the truncation flag was being set too
liberally.
Solution: Make the truncation condition more precise by only setting it
when there's exactly one character of space remaining
(glepnir).
closes: vim/vim#17108
32f2bb6e1e
Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
@@ -688,6 +688,9 @@ void pum_redraw(void)
|
|||||||
int width = 0;
|
int width = 0;
|
||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
p = pum_get_item(idx, item_type);
|
p = pum_get_item(idx, item_type);
|
||||||
|
|
||||||
|
const bool next_isempty = j + 1 < 3 && pum_get_item(idx, order[j + 1]) == NULL;
|
||||||
|
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
for (;; MB_PTR_ADV(p)) {
|
for (;; MB_PTR_ADV(p)) {
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
@@ -721,12 +724,12 @@ void pum_redraw(void)
|
|||||||
char *rt = reverse_text(st);
|
char *rt = reverse_text(st);
|
||||||
char *rt_start = rt;
|
char *rt_start = rt;
|
||||||
int cells = (int)mb_string2cells(rt);
|
int cells = (int)mb_string2cells(rt);
|
||||||
if (pum_width == p_pmw
|
int pad = next_isempty ? 0 : 2;
|
||||||
&& (pum_width - totwidth < cells
|
if (pum_width == p_pmw && pum_width - totwidth < cells + pad) {
|
||||||
|| (j + 1 < 3 && pum_get_item(idx, order[j + 1]) != NULL))) {
|
|
||||||
need_fcs_trunc = true;
|
need_fcs_trunc = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only draw the text that fits
|
||||||
if (grid_col - cells < col_off - pum_width) {
|
if (grid_col - cells < col_off - pum_width) {
|
||||||
do {
|
do {
|
||||||
cells -= utf_ptr2cells(rt);
|
cells -= utf_ptr2cells(rt);
|
||||||
@@ -752,9 +755,8 @@ void pum_redraw(void)
|
|||||||
grid_col -= width;
|
grid_col -= width;
|
||||||
} else {
|
} else {
|
||||||
int cells = (int)mb_string2cells(st);
|
int cells = (int)mb_string2cells(st);
|
||||||
if (pum_width == p_pmw
|
int pad = next_isempty ? 0 : 2;
|
||||||
&& (pum_width - totwidth < cells
|
if (pum_width == p_pmw && pum_width - totwidth < cells + pad) {
|
||||||
|| (j + 1 < 3 && pum_get_item(idx, order[j + 1]) != NULL))) {
|
|
||||||
need_fcs_trunc = true;
|
need_fcs_trunc = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -796,10 +798,6 @@ void pum_redraw(void)
|
|||||||
n = order[j] == CPT_ABBR ? 1 : 0;
|
n = order[j] == CPT_ABBR ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool next_isempty = false;
|
|
||||||
if (j + 1 < 3) {
|
|
||||||
next_isempty = pum_get_item(idx, order[j + 1]) == NULL;
|
|
||||||
}
|
|
||||||
// Stop when there is nothing more to display.
|
// Stop when there is nothing more to display.
|
||||||
if ((j == 2)
|
if ((j == 2)
|
||||||
|| (next_isempty && (j == 1 || (j == 0 && pum_get_item(idx, order[j + 2]) == NULL)))
|
|| (next_isempty && (j == 1 || (j == 0 && pum_get_item(idx, order[j + 2]) == NULL)))
|
||||||
|
Reference in New Issue
Block a user