From 7795829767818a3c6cbeed7957a1ad5c03d48d41 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 3 Jun 2018 19:31:37 -0400 Subject: 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 --- src/nvim/option.c | 7 ++----- src/nvim/options.lua | 2 +- src/nvim/testdir/test_alot.vim | 1 + src/nvim/testdir/test_scroll_opt.vim | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 src/nvim/testdir/test_scroll_opt.vim (limited to 'src') 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 -- cgit