neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 69af5e8782e601fe9c1e39adf49ce16728719a73
parent 9128fc79f0630e0d1e5bedf9bd32417ecd42c4f5
Author: Luuk van Baal <luukvbaal@gmail.com>
Date:   Wed, 26 Apr 2023 04:00:38 +0200

vim-patch:9.0.0645: CTRL-Y does not stop at line 1

Problem:    CTRL-Y does not stop at line 1. (John Marriott)
Solution:   Stop at line 1 when 'smoothscroll' is not set. (closes vim/vim#11261)

https://github.com/vim/vim/commit/8df9748edb2ac8bd025e34e06194ac210667c97a

Co-authored-by: Bram Moolenaar <Bram@vim.org>

Diffstat:
Msrc/nvim/move.c | 5++++-
Mtest/functional/legacy/scroll_opt_spec.lua | 13+++++++++++++
Mtest/old/testdir/test_scroll_opt.vim | 13+++++++++++++
3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/nvim/move.c b/src/nvim/move.c @@ -1109,10 +1109,12 @@ bool scrolldown(long line_count, int byfold) curwin->w_topfill++; done++; } else { - if (curwin->w_topline == 1 && curwin->w_skipcol < width1) { + // break when at the very top + if (curwin->w_topline == 1 && (!curwin->w_p_sms || curwin->w_skipcol < width1)) { break; } if (curwin->w_p_wrap && curwin->w_p_sms && curwin->w_skipcol >= width1) { + // scroll a screen line down if (curwin->w_skipcol >= width1 + width2) { curwin->w_skipcol -= width2; } else { @@ -1121,6 +1123,7 @@ bool scrolldown(long line_count, int byfold) redraw_later(curwin, UPD_NOT_VALID); done++; } else { + // scroll a text line down curwin->w_topline--; curwin->w_skipcol = 0; curwin->w_topfill = 0; diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua @@ -14,6 +14,19 @@ describe('smoothscroll', function() screen:attach() end) + -- oldtest: Test_CtrlE_CtrlY_stop_at_end() + it('disabled does not break <C-E> and <C-Y> stop at end', function() + exec([[ + enew + call setline(1, ['one', 'two']) + set number + ]]) + feed('<C-Y>') + screen:expect({any = " 1 ^one"}) + feed('<C-E><C-E><C-E>') + screen:expect({any = " 2 ^two"}) + end) + -- oldtest: Test_smoothscroll_CtrlE_CtrlY() it('works with <C-E> and <C-E>', function() exec([[ diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim @@ -54,6 +54,19 @@ func Test_scolloff_even_line_count() bwipe! endfunc +func Test_CtrlE_CtrlY_stop_at_end() + enew + call setline(1, ['one', 'two']) + set number + exe "normal \<C-Y>" + call assert_equal([" 1 one "], ScreenLines(1, 10)) + exe "normal \<C-E>\<C-E>\<C-E>" + call assert_equal([" 2 two "], ScreenLines(1, 10)) + + bwipe! + set nonumber +endfunc + func Test_smoothscroll_CtrlE_CtrlY() CheckScreendump