aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2020-11-17 15:25:11 +0100
committerGitHub <noreply@github.com>2020-11-17 15:25:11 +0100
commit8c4648421a1e34c3e95e42ea596de36987f02563 (patch)
tree7b9c7bf501052d76ff6c402b370b0aac08964718 /src
parentce70edb80e965c90fadafea72d758b4d2d531077 (diff)
parentb98348258d6bb4476d5de822369687f2b70d05b7 (diff)
downloadrneovim-8c4648421a1e34c3e95e42ea596de36987f02563.tar.gz
rneovim-8c4648421a1e34c3e95e42ea596de36987f02563.tar.bz2
rneovim-8c4648421a1e34c3e95e42ea596de36987f02563.zip
Merge pull request #13308 from Shougo/vim-8.2.1995
vim-patch:8.2.1995: the popup menu can cause too much redrawing
Diffstat (limited to 'src')
-rw-r--r--src/nvim/popupmnu.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c
index ac0c1f6eb1..f242b7d71a 100644
--- a/src/nvim/popupmnu.c
+++ b/src/nvim/popupmnu.c
@@ -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
// room the window size will keep changing.
} while (pum_set_selected(selected, redo_count) && (++redo_count <= 2));
+
+ pum_redraw();
}
/// Redraw the popup menu, using "pum_first" and "pum_selected".
@@ -534,7 +536,17 @@ void pum_redraw(void)
xfree(st);
col -= width;
} 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);
col += width;
}
@@ -824,10 +836,6 @@ static int pum_set_selected(int n, int repeat)
}
}
- if (!resized) {
- pum_redraw();
- }
-
return resized;
}