summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-02-10 14:56:11 +0100
committerBram Moolenaar <Bram@vim.org>2021-02-10 14:56:11 +0100
commit82db31c10470b0e27d7039d15c32ed7e9417cc02 (patch)
tree7fb45f0c12a291615d822b48865fe696f1fac866
parent4223d43c0fb6ead1e611e4469a1680a9228b6015 (diff)
downloadvim-git-82db31c10470b0e27d7039d15c32ed7e9417cc02.tar.gz
patch 8.2.2491: popup window for text property may show in first screen linev8.2.2491
Problem: Popup window for text property may show in first screen line. Solution: If the text position is invisible do not show the popup window. (closes #7807)
-rw-r--r--src/popupwin.c6
-rw-r--r--src/testdir/dumps/Test_popup_prop_not_visible_01.dump10
-rw-r--r--src/testdir/dumps/Test_popup_prop_not_visible_02.dump10
-rw-r--r--src/testdir/dumps/Test_popup_prop_not_visible_03.dump10
-rw-r--r--src/testdir/test_popupwin.vim43
-rw-r--r--src/version.c2
6 files changed, 81 insertions, 0 deletions
diff --git a/src/popupwin.c b/src/popupwin.c
index 47e7338b7..b0895528e 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -1193,6 +1193,12 @@ popup_adjust_position(win_T *wp)
textpos2screenpos(prop_win, &pos, &screen_row,
&screen_scol, &screen_ccol, &screen_ecol);
+ if (screen_scol == 0)
+ {
+ // position is off screen, make the width zero to hide it.
+ wp->w_width = 0;
+ return;
+ }
if (wp->w_popup_pos == POPPOS_TOPLEFT
|| wp->w_popup_pos == POPPOS_TOPRIGHT)
// below the text
diff --git a/src/testdir/dumps/Test_popup_prop_not_visible_01.dump b/src/testdir/dumps/Test_popup_prop_not_visible_01.dump
new file mode 100644
index 000000000..dbcfda116
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_prop_not_visible_01.dump
@@ -0,0 +1,10 @@
+| +2&#ffffff0|2+2#e000e06&|++2#0000000&| |[|N|o| |N|a|m|e|]| | +1&&@60
+| +0&&@42||+1&&> +0&&@30
+|~+0#4040ff13&| @41||+1#0000000&|s+0&&|o|m|e| |t|e|x|t|a+0#ffffff16#e000002|t@1|a|c|h|e|d| |t|o| |"|s|o|m|e|"| +0#0000000#ffffff0@3
+|~+0#4040ff13&| @41||+1#0000000&| +0&&@30
+|~+0#4040ff13&| @41||+1#0000000&|o+0&&|t|h|e|r| |t|e|x|t|a+0#ffffff16#e000002|t@1|a|c|h|e|d| |t|o| |"|o|t|h|e|r|"| +0#0000000#ffffff0@1
+|~+0#4040ff13&| @41||+1#0000000&|~+0#4040ff13&| @29
+|~| @41||+1#0000000&|~+0#4040ff13&| @29
+|~| @41||+1#0000000&|~+0#4040ff13&| @29
+|[+1#0000000&|N|o| |N|a|m|e|]| @15|0|,|0|-|1| @9|A|l@1| |[+3&&|N|o| |N|a|m|e|]| |[|+|]| @2|1|,|0|-|1| @6|A|l@1
+| +0&&@74
diff --git a/src/testdir/dumps/Test_popup_prop_not_visible_02.dump b/src/testdir/dumps/Test_popup_prop_not_visible_02.dump
new file mode 100644
index 000000000..1d1a5531c
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_prop_not_visible_02.dump
@@ -0,0 +1,10 @@
+| +2&#ffffff0|2+2#e000e06&|++2#0000000&| |[|N|o| |N|a|m|e|]| | +1&&@60
+| +0&&@56||+1&&> +0&&@16
+|~+0#4040ff13&| @55||+1#0000000&|s+0&&|o|m|e| |t|e|x|t|a+0#ffffff16#e000002|t@1|a|c|h|e|d
+|~+0#4040ff13#ffffff0| @55||+1#0000000&| +0&&@16
+|~+0#4040ff13&| @54|a+0#ffffff16#e000002|t@1|a|c|h|e|d| |t|o| |"|o|t|h|e|r|"
+|~+0#4040ff13#ffffff0| @55||+1#0000000&|~+0#4040ff13&| @15
+|~| @55||+1#0000000&|~+0#4040ff13&| @15
+|~| @55||+1#0000000&|~+0#4040ff13&| @15
+|[+1#0000000&|N|o| |N|a|m|e|]| @29|0|,|0|-|1| @9|A|l@1| |<+3&&|m|e|]| |[|+|]| |1|,|0|-|1| @2
+|:+0&&|v|e|r|t| |r|e|s|i|z|e| |-|1|4| @58
diff --git a/src/testdir/dumps/Test_popup_prop_not_visible_03.dump b/src/testdir/dumps/Test_popup_prop_not_visible_03.dump
new file mode 100644
index 000000000..caaa881fe
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_prop_not_visible_03.dump
@@ -0,0 +1,10 @@
+| +2&#ffffff0|2+2#e000e06&|++2#0000000&| |[|N|o| |N|a|m|e|]| | +1&&@60
+| +0&&@64||+1&&> +0&&@8
+|~+0#4040ff13&| @63||+1#0000000&|s+0&&|o|m|e| |t|e|x|t
+|~+0#4040ff13&| @63||+1#0000000&| +0&&@8
+|~+0#4040ff13&| @63||+1#0000000&|o+0&&|t|h|e|r| |t|e|x
+|~+0#4040ff13&| @63||+1#0000000&|~+0#4040ff13&| @7
+|~| @63||+1#0000000&|~+0#4040ff13&| @7
+|~| @63||+1#0000000&|~+0#4040ff13&| @7
+|[+1#0000000&|N|o| |N|a|m|e|]| @37|0|,|0|-|1| @9|A|l@1| |<+3&&|[|+|]| |1|,|0|-
+|:+0&&|v|e|r|t| |r|e|s|i|z|e| |-|8| @59
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index 0d9d326bc..7f5895f96 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -3836,4 +3836,47 @@ func Test_popup_setoptions_other_tab()
call prop_type_delete('textprop')
endfunc
+func Test_popup_prop_not_visible()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ set nowrap stal=2
+ rightbelow :31vnew
+ setline(1, ['', 'some text', '', 'other text'])
+ prop_type_add('someprop', {})
+ prop_add(2, 9, {type: 'someprop', length: 5})
+ popup_create('attached to "some"', {
+ textprop: 'someprop',
+ highlight: 'ErrorMsg',
+ line: -1,
+ wrap: false,
+ fixed: true,
+ })
+ prop_type_add('otherprop', {})
+ prop_add(4, 10, {type: 'otherprop', length: 5})
+ popup_create('attached to "other"', {
+ textprop: 'otherprop',
+ highlight: 'ErrorMsg',
+ line: -1,
+ wrap: false,
+ fixed: false,
+ })
+ END
+ call writefile(lines, 'XtestPropNotVisble')
+ let buf = RunVimInTerminal('-S XtestPropNotVisble', #{rows: 10})
+ call VerifyScreenDump(buf, 'Test_popup_prop_not_visible_01', {})
+
+ call term_sendkeys(buf, ":vert resize -14\<CR>")
+ call VerifyScreenDump(buf, 'Test_popup_prop_not_visible_02', {})
+
+ call term_sendkeys(buf, ":vert resize -8\<CR>")
+ call VerifyScreenDump(buf, 'Test_popup_prop_not_visible_03', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XtestPropNotVisble')
+endfunction
+
+
" vim: shiftwidth=2 sts=2
diff --git a/src/version.c b/src/version.c
index 382b923a9..9c738bffa 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2491,
+/**/
2490,
/**/
2489,