Mercurial > vim
diff src/popupwin.c @ 17879:5d5b460926ca v8.1.1936
patch 8.1.1936: not enough tests for text property popup window
Commit: https://github.com/vim/vim/commit/1fb0831a0e9f9b6f18f1f8b549191bd547d0e095
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 29 20:02:11 2019 +0200
patch 8.1.1936: not enough tests for text property popup window
Problem: Not enough tests for text property popup window.
Solution: Add a few more tests. Make negative offset work. Close all
popups when window closes.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 29 Aug 2019 20:15:04 +0200 |
parents | f13a5c48320b |
children | fa032e079825 |
line wrap: on
line diff
--- a/src/popupwin.c +++ b/src/popupwin.c @@ -33,6 +33,7 @@ static void popup_adjust_position(win_T /* * Get option value for "key", which is "line" or "col". * Handles "cursor+N" and "cursor-N". + * Returns MAXCOL if the entry is not present. */ static int popup_options_one(dict_T *dict, char_u *key) @@ -45,7 +46,7 @@ popup_options_one(dict_T *dict, char_u * di = dict_find(dict, key, -1); if (di == NULL) - return 0; + return MAXCOL; val = tv_get_string(&di->di_tv); if (STRNCMP(val, "cursor", 6) != 0) @@ -408,10 +409,10 @@ apply_move_options(win_T *wp, dict_T *d) wp->w_maxheight = nr; nr = popup_options_one(d, (char_u *)"line"); - if (nr > 0) + if (nr != MAXCOL) wp->w_wantline = nr; nr = popup_options_one(d, (char_u *)"col"); - if (nr > 0) + if (nr != MAXCOL) wp->w_wantcol = nr; di = dict_find(d, (char_u *)"fixed", -1); @@ -1114,7 +1115,7 @@ popup_adjust_position(win_T *wp) } else { - if (wantline != 0 && (wp->w_popup_pos == POPPOS_TOPLEFT + if (wantline > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT || wp->w_popup_pos == POPPOS_TOPRIGHT)) { wp->w_winrow = wantline - 1; @@ -1124,8 +1125,8 @@ popup_adjust_position(win_T *wp) if (wantcol == 0) center_hor = TRUE; - else if (wp->w_popup_pos == POPPOS_TOPLEFT - || wp->w_popup_pos == POPPOS_BOTLEFT) + else if (wantcol > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT + || wp->w_popup_pos == POPPOS_BOTLEFT)) { wp->w_wincol = wantcol - 1; if (wp->w_wincol >= Columns - 3) @@ -3587,21 +3588,23 @@ popup_hide_info(void) int popup_win_closed(win_T *win) { - win_T *wp; - - for (wp = first_popupwin; wp != NULL; wp = wp->w_next) - if (wp->w_popup_prop_win == win) + int round; + win_T *wp; + win_T *next; + int ret = FALSE; + + for (round = 1; round <= 2; ++round) + for (wp = round == 1 ? first_popupwin : curtab->tp_first_popupwin; + wp != NULL; wp = next) { - popup_close_with_retval(wp, -1); - return TRUE; + next = wp->w_next; + if (wp->w_popup_prop_win == win) + { + popup_close_with_retval(wp, -1); + ret = TRUE; + } } - for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next) - if (wp->w_popup_prop_win == win) - { - popup_close_with_retval(wp, -1); - return TRUE; - } - return FALSE; + return ret; } /*