summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-06 20:17:35 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-06 20:17:35 +0100
commitbef93ac9dbfb98193ddb315c50523f1af01a517d (patch)
treee20d644144916affab27f34da5631827aac9268d /src
parent9a838fe543b69582b0773f7c38a57f16fb32d765 (diff)
downloadvim-git-bef93ac9dbfb98193ddb315c50523f1af01a517d.tar.gz
patch 8.1.2399: info popup on top of cursor if it doesn't fitv8.1.2399
Problem: Info popup on top of cursor if it doesn't fit. Solution: Hide the popup if it doesn't fit.
Diffstat (limited to 'src')
-rw-r--r--src/popupmenu.c8
-rw-r--r--src/testdir/dumps/Test_popupwin_infopopup_wide_1.dump8
-rw-r--r--src/testdir/test_popupwin.vim52
-rw-r--r--src/version.c2
4 files changed, 69 insertions, 1 deletions
diff --git a/src/popupmenu.c b/src/popupmenu.c
index 14539adf2..ceb72b4f2 100644
--- a/src/popupmenu.c
+++ b/src/popupmenu.c
@@ -661,7 +661,13 @@ pum_position_info_popup(win_T *wp)
// align with the selected item
row += pum_selected - pum_first + 1;
- popup_set_wantpos_rowcol(wp, row, col);
+ wp->w_popup_flags &= ~POPF_HIDDEN;
+ if (wp->w_maxwidth < 10)
+ // The popup is not going to fit or will overlap with the cursor
+ // position, hide the popup.
+ wp->w_popup_flags |= POPF_HIDDEN;
+ else
+ popup_set_wantpos_rowcol(wp, row, col);
}
#endif
diff --git a/src/testdir/dumps/Test_popupwin_infopopup_wide_1.dump b/src/testdir/dumps/Test_popupwin_infopopup_wide_1.dump
new file mode 100644
index 000000000..f7b583ba5
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_infopopup_wide_1.dump
@@ -0,0 +1,8 @@
+|s+0&#ffffff0|c|r|a|p> @69
+|s+0#0000001#e0e0e08|c|r|a|p| @5|s|o|m|e| |l|o|n|g| |t|e|x|t| |t|o| |m|a|k|e| |s|u|r|e| |t|h|e| |m|e|n|u| |t|a|k|e|s| |u|p| |a|l@1| |o|f| |t|h|e| |w|i|d|t|h| |o
+|s+0&#ffd7ff255|c|a|p@1|i|e|r| @2|s|o|m|e| |l|o|n|g| |t|e|x|t| |t|o| |m|a|k|e| |s|u|r|e| |t|h|e| |m|e|n|u| |t|a|k|e|s| |u|p| |a|l@1| |o|f| |t|h|e| |w|i|d|t|h| |o
+|s|c|r|a|p@1|i|e|r|2| |s|o|m|e| |l|o|n|g| |t|e|x|t| |t|o| |m|a|k|e| |s|u|r|e| |t|h|e| |m|e|n|u| |t|a|k|e|s| |u|p| |a|l@1| |o|f| |t|h|e| |w|i|d|t|h| |o
+|4+0#0000000#ffffff0| @73
+|5| @73
+|6| @73
+|-+2&&@1| |O|m|n|i| |c|o|m|p|l|e|t|i|o|n| |(|^|O|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |3| +0#0000000&@34
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index 6bfc6dd43..dc2274346 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -2982,6 +2982,58 @@ func Test_popupmenu_info_hidden()
call delete('XtestInfoPopupHidden')
endfunc
+func Test_popupmenu_info_too_wide()
+ CheckScreendump
+ CheckFeature quickfix
+
+ let lines =<< trim END
+ call setline(1, range(10))
+
+ set completeopt+=preview,popup
+ set completepopup=align:menu
+ set omnifunc=OmniFunc
+ hi InfoPopup ctermbg=lightgrey
+
+ func OmniFunc(findstart, base)
+ if a:findstart
+ return 0
+ endif
+
+ let menuText = 'some long text to make sure the menu takes up all of the width of the window'
+ return #{
+ \ words: [
+ \ #{
+ \ word: 'scrap',
+ \ menu: menuText,
+ \ info: "other words are\ncooler than this and some more text\nto make wrap",
+ \ },
+ \ #{
+ \ word: 'scappier',
+ \ menu: menuText,
+ \ info: 'words are cool',
+ \ },
+ \ #{
+ \ word: 'scrappier2',
+ \ menu: menuText,
+ \ info: 'words are cool',
+ \ },
+ \ ]
+ \ }
+ endfunc
+ END
+
+ call writefile(lines, 'XtestInfoPopupWide')
+ let buf = RunVimInTerminal('-S XtestInfoPopupWide', #{rows: 8})
+ call term_wait(buf, 50)
+
+ call term_sendkeys(buf, "Ascr\<C-X>\<C-O>")
+ call VerifyScreenDump(buf, 'Test_popupwin_infopopup_wide_1', {})
+
+ call term_sendkeys(buf, "\<Esc>")
+ call StopVimInTerminal(buf)
+ call delete('XtestInfoPopupWide')
+endfunc
+
func Test_popupwin_recycle_bnr()
let bufnr = popup_notification('nothing wrong', {})->winbufnr()
call popup_clear()
diff --git a/src/version.c b/src/version.c
index 0cb4bddff..4ca28a529 100644
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2399,
+/**/
2398,
/**/
2397,