diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2018-06-03 19:31:37 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-06-04 01:31:37 +0200 |
commit | 7795829767818a3c6cbeed7957a1ad5c03d48d41 (patch) | |
tree | 9c79b6783dc90c93c5db95f6f9b03e48898a1e43 /src | |
parent | 807a16dbc1c6acdf573f6601cb3e6e15843800d6 (diff) | |
download | rneovim-7795829767818a3c6cbeed7957a1ad5c03d48d41.tar.gz rneovim-7795829767818a3c6cbeed7957a1ad5c03d48d41.tar.bz2 rneovim-7795829767818a3c6cbeed7957a1ad5c03d48d41.zip |
vim-patch:8.0.1237: ":set scroll&" often gives an error (#8473)
Problem: ":set scroll&" often gives an error.
Solution: Don't use a fixed default value, use half the window height. Add a
test. (Ozaki Kiichi, closes vim/vim#2104)
https://github.com/vim/vim/commit/af2d20c6285c1d2973e3d9b5e8f727e3ed180493
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/option.c | 7 | ||||
-rw-r--r-- | src/nvim/options.lua | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_alot.vim | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_scroll_opt.vim | 36 |
4 files changed, 40 insertions, 6 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index 88c458b597..26fc164c6c 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -939,11 +939,8 @@ void set_init_2(bool headless) { int idx; - /* - * 'scroll' defaults to half the window height. Note that this default is - * wrong when the window height changes. - */ - set_number_default("scroll", Rows / 2); + // 'scroll' defaults to half the window height. The stored default is zero, + // which results in the actual value computed from the window height. idx = findoption("scroll"); if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) { set_option_default(idx, OPT_LOCAL, p_cp); diff --git a/src/nvim/options.lua b/src/nvim/options.lua index f1f559fff0..47c9f5aa78 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -1922,7 +1922,7 @@ return { no_mkrc=true, vi_def=true, pv_name='p_scroll', - defaults={if_true={vi=12}} + defaults={if_true={vi=0}} }, { full_name='scrollback', abbreviation='scbk', diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index b4baf7a8d7..c4b4a43ad4 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -27,6 +27,7 @@ source test_popup.vim source test_put.vim source test_recover.vim source test_regexp_utf8.vim +source test_scroll_opt.vim source test_source_utf8.vim source test_sha256.vim source test_statusline.vim diff --git a/src/nvim/testdir/test_scroll_opt.vim b/src/nvim/testdir/test_scroll_opt.vim new file mode 100644 index 0000000000..77920eb8b0 --- /dev/null +++ b/src/nvim/testdir/test_scroll_opt.vim @@ -0,0 +1,36 @@ +" Test for reset 'scroll' +" + +func Test_reset_scroll() + let scr = &l:scroll + + setlocal scroll=1 + setlocal scroll& + call assert_equal(scr, &l:scroll) + + setlocal scroll=1 + setlocal scroll=0 + call assert_equal(scr, &l:scroll) + + try + execute 'setlocal scroll=' . (winheight(0) + 1) + " not reached + call assert_false(1) + catch + call assert_exception('E49:') + endtry + + split + + let scr = &l:scroll + + setlocal scroll=1 + setlocal scroll& + call assert_equal(scr, &l:scroll) + + setlocal scroll=1 + setlocal scroll=0 + call assert_equal(scr, &l:scroll) + + quit! +endfunc |