comparison src/popupmenu.c @ 21377:47f25a0c5a42 v8.2.1239

patch 8.2.1239: "maxwidth" in 'completepopup' not obeyed Commit: https://github.com/vim/vim/commit/de2396fc875837c47b1c13f5e80e0a1200c5eb61 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jul 18 21:40:41 2020 +0200 patch 8.2.1239: "maxwidth" in 'completepopup' not obeyed Problem: "maxwidth" in 'completepopup' not obeyed. (Jay Sitter) Solution: Add separate field for value from option. (closes https://github.com/vim/vim/issues/6470)
author Bram Moolenaar <Bram@vim.org>
date Sat, 18 Jul 2020 21:45:03 +0200
parents d571231175b4
children 68dc849715b5
comparison
equal deleted inserted replaced
21376:8c028ece0248 21377:47f25a0c5a42
640 pum_position_info_popup(win_T *wp) 640 pum_position_info_popup(win_T *wp)
641 { 641 {
642 int col = pum_col + pum_width + pum_scrollbar + 1; 642 int col = pum_col + pum_width + pum_scrollbar + 1;
643 int row = pum_row; 643 int row = pum_row;
644 int botpos = POPPOS_BOTLEFT; 644 int botpos = POPPOS_BOTLEFT;
645 int used_maxwidth_opt = FALSE;
645 646
646 wp->w_popup_pos = POPPOS_TOPLEFT; 647 wp->w_popup_pos = POPPOS_TOPLEFT;
647 if (Columns - col < 20 && Columns - col < pum_col) 648 if (Columns - col < 20 && Columns - col < pum_col)
648 { 649 {
649 col = pum_col - 1; 650 col = pum_col - 1;
652 wp->w_maxwidth = pum_col - 1; 653 wp->w_maxwidth = pum_col - 1;
653 } 654 }
654 else 655 else
655 wp->w_maxwidth = Columns - col + 1; 656 wp->w_maxwidth = Columns - col + 1;
656 wp->w_maxwidth -= popup_extra_width(wp); 657 wp->w_maxwidth -= popup_extra_width(wp);
658 if (wp->w_maxwidth_opt > 0 && wp->w_maxwidth > wp->w_maxwidth_opt)
659 {
660 // option value overrules computed value
661 wp->w_maxwidth = wp->w_maxwidth_opt;
662 used_maxwidth_opt = TRUE;
663 }
657 664
658 row -= popup_top_extra(wp); 665 row -= popup_top_extra(wp);
659 if (wp->w_popup_flags & POPF_INFO_MENU) 666 if (wp->w_popup_flags & POPF_INFO_MENU)
660 { 667 {
661 if (pum_row < pum_win_row) 668 if (pum_row < pum_win_row)
671 else 678 else
672 // align with the selected item 679 // align with the selected item
673 row += pum_selected - pum_first + 1; 680 row += pum_selected - pum_first + 1;
674 681
675 wp->w_popup_flags &= ~POPF_HIDDEN; 682 wp->w_popup_flags &= ~POPF_HIDDEN;
676 if (wp->w_maxwidth < 10) 683 if (wp->w_maxwidth < 10 && !used_maxwidth_opt)
677 // The popup is not going to fit or will overlap with the cursor 684 // The popup is not going to fit or will overlap with the cursor
678 // position, hide the popup. 685 // position, hide the popup.
679 wp->w_popup_flags |= POPF_HIDDEN; 686 wp->w_popup_flags |= POPF_HIDDEN;
680 else 687 else
681 popup_set_wantpos_rowcol(wp, row, col); 688 popup_set_wantpos_rowcol(wp, row, col);