diff options
Diffstat (limited to 'src/nvim/popupmnu.c')
-rw-r--r-- | src/nvim/popupmnu.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index 1ea12d6862..10012a9775 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -2,6 +2,7 @@ /// /// Popup menu (PUM) // +#include <assert.h> #include <inttypes.h> #include <stdbool.h> @@ -17,6 +18,7 @@ #include "nvim/screen.h" #include "nvim/search.h" #include "nvim/strings.h" +#include "nvim/memory.h" #include "nvim/window.h" #include "nvim/edit.h" @@ -101,7 +103,7 @@ redo: } if ((p_ph > 0) && (pum_height > p_ph)) { - pum_height = p_ph; + pum_height = (int)p_ph; } // Put the pum below "row" if possible. If there are few lines decide on @@ -126,8 +128,8 @@ redo: } if ((p_ph > 0) && (pum_height > p_ph)) { - pum_row += pum_height - p_ph; - pum_height = p_ph; + pum_row += pum_height - (int)p_ph; + pum_height = (int)p_ph; } } else { // pum below "row" @@ -148,7 +150,7 @@ redo: } if ((p_ph > 0) && (pum_height > p_ph)) { - pum_height = p_ph; + pum_height = (int)p_ph; } } @@ -219,7 +221,9 @@ redo: if (curwin->w_p_rl) { pum_width = pum_col - pum_scrollbar + 1; } else { - pum_width = Columns - pum_col - pum_scrollbar; + assert(Columns - pum_col - pum_scrollbar >= INT_MIN + && Columns - pum_col - pum_scrollbar <= INT_MAX); + pum_width = (int)(Columns - pum_col - pum_scrollbar); } if ((pum_width > max_width + kind_width + extra_width + 1) @@ -233,11 +237,13 @@ redo: } else if (Columns < def_width) { // not enough room, will use what we have if (curwin->w_p_rl) { - pum_col = Columns - 1; + assert(Columns - 1 >= INT_MIN); + pum_col = (int)(Columns - 1); } else { pum_col = 0; } - pum_width = Columns - 1; + assert(Columns - 1 >= INT_MIN); + pum_width = (int)(Columns - 1); } else { if (max_width > PUM_DEF_WIDTH) { // truncate @@ -247,7 +253,8 @@ redo: if (curwin->w_p_rl) { pum_col = max_width - 1; } else { - pum_col = Columns - max_width; + assert(Columns - max_width >= INT_MIN && Columns - max_width <= INT_MAX); + pum_col = (int)(Columns - max_width); } pum_width = max_width - pum_scrollbar; } @@ -345,7 +352,7 @@ void pum_redraw(void) // Display the text that fits or comes before a Tab. // First convert it to printable characters. char_u *st; - int saved = *p; + char_u saved = *p; *p = NUL; st = transstr(s); @@ -371,12 +378,12 @@ void pum_redraw(void) } } screen_puts_len(rt, (int)STRLEN(rt), row, col - size + 1, attr); - free(rt_start); - free(st); + xfree(rt_start); + xfree(st); col -= width; } else { screen_puts_len(st, (int)STRLEN(st), row, col, attr); - free(st); + xfree(st); col += width; } @@ -535,7 +542,7 @@ static int pum_set_selected(int n, int repeat) g_do_tagpreview = 3; if ((p_pvh > 0) && (p_pvh < g_do_tagpreview)) { - g_do_tagpreview = p_pvh; + g_do_tagpreview = (int)p_pvh; } RedrawingDisabled++; resized = prepare_tagpreview(false); |