summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-09-01 17:38:09 +0200
committerBram Moolenaar <Bram@vim.org>2019-09-01 17:38:09 +0200
commita112f2d0035b0800b4a70dbb6f0e5f85e8ec84e5 (patch)
tree9ad9ce411790e0ab4f4b204fcc5d1a8be05ec40c
parentc33083592846c8d4b2d6fae499536b9d578fe10d (diff)
downloadvim-git-a112f2d0035b0800b4a70dbb6f0e5f85e8ec84e5.tar.gz
patch 8.1.1959: when using "firstline" in popup window text may jumpv8.1.1959
Problem: When using "firstline" in popup window text may jump when redrawing it. (Nick Jensen) Solution: Set 'scrolloff' to zero in a popup window. (closes #4882)
-rw-r--r--src/popupwin.c3
-rw-r--r--src/testdir/dumps/Test_popupwin_scroll_5.dump8
-rw-r--r--src/testdir/dumps/Test_popupwin_scroll_6.dump8
-rw-r--r--src/testdir/test_popupwin.vim27
-rw-r--r--src/version.c2
5 files changed, 37 insertions, 11 deletions
diff --git a/src/popupwin.c b/src/popupwin.c
index c277de29e..714529181 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -1687,11 +1687,12 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
buf->b_p_swf = FALSE; // no swap file
buf->b_p_bl = FALSE; // unlisted buffer
buf->b_locked = TRUE;
- wp->w_p_wrap = TRUE; // 'wrap' is default on
// Avoid that 'buftype' is reset when this buffer is entered.
buf->b_p_initialized = TRUE;
}
+ wp->w_p_wrap = TRUE; // 'wrap' is default on
+ wp->w_p_so = 0; // 'scrolloff' zero
if (tp != NULL)
{
diff --git a/src/testdir/dumps/Test_popupwin_scroll_5.dump b/src/testdir/dumps/Test_popupwin_scroll_5.dump
index fa7ee30f8..c5cbe80ad 100644
--- a/src/testdir/dumps/Test_popupwin_scroll_5.dump
+++ b/src/testdir/dumps/Test_popupwin_scroll_5.dump
@@ -1,10 +1,10 @@
>1+0&#ffffff0| @73
|2| @73
|3| @73
-|4| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#ff404010| +0&#ffffff0@32
-|5| @31|f+0#0000001#ffd7ff255|i|v|e| @3| +0#0000000#4040ff13| +0&#ffffff0@32
-|6| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#4040ff13| +0&#ffffff0@32
-|7| @31|s+0#0000001#ffd7ff255|e|v|e|n| @2| +0#0000000#ff404010| +0&#ffffff0@32
+|4| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#ff404010| +0&#ffffff0@32
+|5| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#4040ff13| +0&#ffffff0@32
+|6| @31|f+0#0000001#ffd7ff255|i|v|e| @3| +0#0000000#4040ff13| +0&#ffffff0@32
+|7| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#ff404010| +0&#ffffff0@32
|8| @73
|9| @73
|:|c|a|l@1| |S|c|r|o|l@1|U|p|(|)| @40|1|,|1| @10|T|o|p|
diff --git a/src/testdir/dumps/Test_popupwin_scroll_6.dump b/src/testdir/dumps/Test_popupwin_scroll_6.dump
index 1ee91b1ed..aade9d015 100644
--- a/src/testdir/dumps/Test_popupwin_scroll_6.dump
+++ b/src/testdir/dumps/Test_popupwin_scroll_6.dump
@@ -1,10 +1,10 @@
>1+0&#ffffff0| @73
|2| @73
|3| @73
-|4| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#ff404010| +0&#ffffff0@32
-|5| @31|s+0#0000001#ffd7ff255|e|v|e|n| @2| +0#0000000#ff404010| +0&#ffffff0@32
-|6| @31|e+0#0000001#ffd7ff255|i|g|h|t| @2| +0#0000000#4040ff13| +0&#ffffff0@32
-|7| @31|n+0#0000001#ffd7ff255|i|n|e| @3| +0#0000000#4040ff13| +0&#ffffff0@32
+|4| @31|f+0#0000001#ffd7ff255|i|v|e| @3| +0#0000000#ff404010| +0&#ffffff0@32
+|5| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#ff404010| +0&#ffffff0@32
+|6| @31|s+0#0000001#ffd7ff255|e|v|e|n| @2| +0#0000000#4040ff13| +0&#ffffff0@32
+|7| @31|e+0#0000001#ffd7ff255|i|g|h|t| @2| +0#0000000#4040ff13| +0&#ffffff0@32
|8| @73
|9| @73
|:|c|a|l@1| |S|c|r|o|l@1|D|o|w|n|(|)| @38|1|,|1| @10|T|o|p|
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index a6d4d622b..f0959e767 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -371,6 +371,24 @@ func Test_popup_firstline()
call popup_close(winid)
endfunc
+func Test_popup_noscrolloff()
+ set scrolloff=5
+ let winid = popup_create(['xxx']->repeat(50), #{
+ \ maxheight: 5,
+ \ firstline: 11,
+ \ })
+ redraw
+ call assert_equal(11, popup_getoptions(winid).firstline)
+ call assert_equal(11, popup_getpos(winid).firstline)
+
+ call popup_setoptions(winid, #{firstline: 0})
+ call win_execute(winid, "normal! \<c-y>")
+ call assert_equal(0, popup_getoptions(winid).firstline)
+ call assert_equal(10, popup_getpos(winid).firstline)
+
+ call popup_close(winid)
+endfunc
+
func Test_popup_drag()
CheckScreendump
@@ -1019,14 +1037,18 @@ func Test_popup_option_values()
" global/buffer-local
setlocal path=/there
" global/window-local
- setlocal scrolloff=9
+ setlocal statusline=2
let winid = popup_create('hello', {})
call assert_equal(0, getwinvar(winid, '&number'))
call assert_equal(1, getwinvar(winid, '&wrap'))
call assert_equal('', getwinvar(winid, '&omnifunc'))
call assert_equal(&g:path, getwinvar(winid, '&path'))
- call assert_equal(&g:scrolloff, getwinvar(winid, '&scrolloff'))
+ call assert_equal(&g:statusline, getwinvar(winid, '&statusline'))
+
+ " 'scrolloff' is reset to zero
+ call assert_equal(5, &scrolloff)
+ call assert_equal(0, getwinvar(winid, '&scrolloff'))
call popup_close(winid)
bwipe
@@ -1713,6 +1735,7 @@ func Test_popup_scrollbar()
call VerifyScreenDump(buf, 'Test_popupwin_scroll_4', {})
call term_sendkeys(buf, ":call popup_setoptions(winid, #{scrollbarhighlight: 'ScrollBar', thumbhighlight: 'ScrollThumb', firstline: 5})\<CR>")
+ " this scrolls two lines (half the window height)
call term_sendkeys(buf, ":call ScrollUp()\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_scroll_5', {})
diff --git a/src/version.c b/src/version.c
index 14842cde4..485af136d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1959,
+/**/
1958,
/**/
1957,