diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-05-09 06:11:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-09 06:11:56 +0800 |
commit | e4e230a0cd1b2b0aaee60a5a4a7fcb8df508e7a0 (patch) | |
tree | ab78ff717818f4896dffa73d8457951408cb15cc | |
parent | 064f3e42e8d33b0a9e560dfb7c9a42b2fc1ed868 (diff) | |
download | rneovim-e4e230a0cd1b2b0aaee60a5a4a7fcb8df508e7a0.tar.gz rneovim-e4e230a0cd1b2b0aaee60a5a4a7fcb8df508e7a0.tar.bz2 rneovim-e4e230a0cd1b2b0aaee60a5a4a7fcb8df508e7a0.zip |
vim-patch:9.1.0397: Wrong display with 'smoothscroll' when changing quickfix list (#28674)
Problem: Wrong display with 'smoothscroll' when changing quickfix list.
Solution: Reset w_skipcol when replacing quickfix list (zeertzjq).
closes: vim/vim#14730
https://github.com/vim/vim/commit/c7a8eb5ff2ddd919e6f39faec93d81c52874695a
-rw-r--r-- | src/nvim/move.c | 1 | ||||
-rw-r--r-- | src/nvim/quickfix.c | 6 | ||||
-rw-r--r-- | test/functional/legacy/scroll_opt_spec.lua | 129 | ||||
-rw-r--r-- | test/old/testdir/test_scroll_opt.vim | 45 |
4 files changed, 165 insertions, 16 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c index 377ccd7596..078ce3d72c 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -286,6 +286,7 @@ void update_topline(win_T *wp) } wp->w_topline = 1; wp->w_botline = 2; + wp->w_skipcol = 0; wp->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP; wp->w_viewport_invalid = true; wp->w_scbind_pos = 1; diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 94e176bd94..2713dd2a45 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4195,6 +4195,12 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int q } } + FOR_ALL_TAB_WINDOWS(tp, wp) { + if (wp->w_buffer == curbuf) { + wp->w_skipcol = 0; + } + } + // Remove all undo information u_clearallandblockfree(curbuf); } diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua index 80b8e72aec..06460a9986 100644 --- a/test/functional/legacy/scroll_opt_spec.lua +++ b/test/functional/legacy/scroll_opt_spec.lua @@ -913,6 +913,119 @@ describe('smoothscroll', function() assert_alive() end) + -- oldtest: Test_smoothscroll_insert_bottom() + it('works in Insert mode at bottom of window', function() + screen:try_resize(40, 9) + exec([[ + call setline(1, repeat([repeat('A very long line ...', 10)], 5)) + set wrap smoothscroll scrolloff=0 + ]]) + feed('Go123456789<CR>') + screen:expect([[ + {1:<<<}ery long line ...A very long line ...| + A very long line ...A very long line ...|*5 + 123456789 | + ^ | + {5:-- INSERT --} | + ]]) + end) + + -- oldtest: Test_smoothscroll_in_qf_window() + it('works in quickfix window when changing quickfix list', function() + screen:try_resize(60, 20) + exec([[ + set nocompatible display=lastline + copen 5 + setlocal number smoothscroll + let g:l = [{'text': 'foo'}] + repeat([{'text': join(range(30))}], 10) + call setqflist(g:l, 'r') + normal! G + wincmd t + let g:l1 = [{'text': join(range(1000))}] + ]]) + screen:expect([[ + ^ | + {1:~ }|*11 + {3:[No Name] }| + {1:<<<}{8: }21 22 23 24 25 26 27 28 29 | + {8: 10 }|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | + {8: }21 22 23 24 25 26 27 28 29 | + {8: 11 }|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | + {8: }21 22 23 24 25 26 27 28 29 | + {2:[Quickfix List] }| + | + ]]) + + feed([[:call setqflist([], 'r')<CR>]]) + local screen_empty = [[ + ^ | + {1:~ }|*11 + {3:[No Name] }| + {8: 1 } | + {1:~ }|*4 + {2:[Quickfix List] }| + :call setqflist([], 'r') | + ]] + screen:expect(screen_empty) + + feed([[:call setqflist(g:l, 'r')<CR>]]) + local screen_l_top = [[ + ^ | + {1:~ }|*11 + {3:[No Name] }| + {8: 1 }{10:|| foo }| + {8: 2 }|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | + {8: }21 22 23 24 25 26 27 28 29 | + {8: 3 }|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | + {8: }21 22 23 24 25 26 27 28 29 | + {2:[Quickfix List] }| + :call setqflist(g:l, 'r') | + ]] + screen:expect(screen_l_top) + + feed([[:call setqflist(g:l1, 'r')<CR>]]) + local screen_l1_top = [[ + ^ | + {1:~ }|*11 + {3:[No Name] }| + {8: 1 }{10:|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 }| + {8: }{10:21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39}| + {8: }{10: 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 5}| + {8: }{10:8 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 }| + {8: }{10:77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95}| + {2:[Quickfix List] }| + :call setqflist(g:l1, 'r') | + ]] + screen:expect(screen_l1_top) + + feed('<C-W>b$<C-W>t') + local screen_l1_bot = [[ + ^ | + {1:~ }|*11 + {3:[No Name] }| + {1:<<<}{8: }{10: 937 938 939 940 941 942 943 944 945 946 947 948 949 950}| + {8: }{10: 951 952 953 954 955 956 957 958 959 960 961 962 963 964}| + {8: }{10: 965 966 967 968 969 970 971 972 973 974 975 976 977 978}| + {8: }{10: 979 980 981 982 983 984 985 986 987 988 989 990 991 992}| + {8: }{10: 993 994 995 996 997 998 999 }| + {2:[Quickfix List] }| + :call setqflist(g:l1, 'r') | + ]] + screen:expect(screen_l1_bot) + + feed([[:call setqflist([], 'r')<CR>]]) + screen:expect(screen_empty) + + feed([[:call setqflist(g:l1, 'r')<CR>]]) + screen:expect(screen_l1_top) + + feed('<C-W>b$<C-W>t') + screen:expect(screen_l1_bot) + + feed([[:call setqflist(g:l, 'r')<CR>]]) + screen:expect(screen_l_top) + end) + it('works with virt_lines above and below', function() screen:try_resize(55, 7) exec([=[ @@ -986,22 +1099,6 @@ describe('smoothscroll', function() ]]) end) - it('works in Insert mode at bottom of window', function() - screen:try_resize(40, 9) - exec([[ - call setline(1, repeat([repeat('A very long line ...', 10)], 5)) - set wrap smoothscroll scrolloff=0 - ]]) - feed('Go123456789<CR>') - screen:expect([[ - {1:<<<}ery long line ...A very long line ...| - A very long line ...A very long line ...|*5 - 123456789 | - ^ | - {5:-- INSERT --} | - ]]) - end) - it('<<< marker shows with tabline, winbar and splits', function() screen:try_resize(40, 12) screen:set_default_attr_ids({ diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim index 50b0e13ba4..c7b986e040 100644 --- a/test/old/testdir/test_scroll_opt.vim +++ b/test/old/testdir/test_scroll_opt.vim @@ -964,6 +964,51 @@ func Test_smoothscroll_insert_bottom() call StopVimInTerminal(buf) endfunc +func Test_smoothscroll_in_qf_window() + CheckFeature quickfix + CheckScreendump + + let lines =<< trim END + set nocompatible display=lastline + copen 5 + setlocal number smoothscroll + let g:l = [{'text': 'foo'}] + repeat([{'text': join(range(30))}], 10) + call setqflist(g:l, 'r') + normal! G + wincmd t + let g:l1 = [{'text': join(range(1000))}] + END + call writefile(lines, 'XSmoothScrollInQfWindow', 'D') + let buf = RunVimInTerminal('-u NONE -S XSmoothScrollInQfWindow', #{rows: 20, cols: 60}) + call VerifyScreenDump(buf, 'Test_smoothscroll_in_qf_window_1', {}) + + call term_sendkeys(buf, ":call setqflist([], 'r')\<CR>") + call VerifyScreenDump(buf, 'Test_smoothscroll_in_qf_window_2', {}) + + call term_sendkeys(buf, ":call setqflist(g:l, 'r')\<CR>") + call VerifyScreenDump(buf, 'Test_smoothscroll_in_qf_window_3', {}) + + call term_sendkeys(buf, ":call setqflist(g:l1, 'r')\<CR>") + call VerifyScreenDump(buf, 'Test_smoothscroll_in_qf_window_4', {}) + + call term_sendkeys(buf, "\<C-W>b$\<C-W>t") + call VerifyScreenDump(buf, 'Test_smoothscroll_in_qf_window_5', {}) + + call term_sendkeys(buf, ":call setqflist([], 'r')\<CR>") + call VerifyScreenDump(buf, 'Test_smoothscroll_in_qf_window_2', {}) + + call term_sendkeys(buf, ":call setqflist(g:l1, 'r')\<CR>") + call VerifyScreenDump(buf, 'Test_smoothscroll_in_qf_window_4', {}) + + call term_sendkeys(buf, "\<C-W>b$\<C-W>t") + call VerifyScreenDump(buf, 'Test_smoothscroll_in_qf_window_5', {}) + + call term_sendkeys(buf, ":call setqflist(g:l, 'r')\<CR>") + call VerifyScreenDump(buf, 'Test_smoothscroll_in_qf_window_3', {}) + + call StopVimInTerminal(buf) +endfunc + func Test_smoothscroll_in_zero_width_window() set cpo+=n number smoothscroll set winwidth=99999 winminwidth=0 |