fix(mouse): ensure no scrolling with "ver:0" in 'mousescroll'

This commit is contained in:
zeertzjq 2022-10-29 22:25:56 +08:00
parent 356244d50b
commit b3360f0734
3 changed files with 20 additions and 2 deletions

View File

@ -4147,7 +4147,7 @@ static void ins_mousescroll(int dir)
if (dir == MSCR_DOWN || dir == MSCR_UP) {
if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) {
scroll_redraw(dir, (long)(curwin->w_botline - curwin->w_topline));
} else {
} else if (p_mousescroll_vert > 0) {
scroll_redraw(dir, p_mousescroll_vert);
}
} else {

View File

@ -3417,7 +3417,7 @@ static void nv_mousescroll(cmdarg_T *cap)
if (cap->arg == MSCR_UP || cap->arg == MSCR_DOWN) {
if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) {
(void)onepage(cap->arg ? FORWARD : BACKWARD, 1L);
} else {
} else if (p_mousescroll_vert > 0) {
cap->count1 = p_mousescroll_vert;
cap->count0 = p_mousescroll_vert;
nv_scroll_line(cap);

View File

@ -97,6 +97,24 @@ describe("'mousescroll'", function()
eq(10, screencol())
scroll('left')
eq(10, screencol())
-- vertical scrolling is still disabled with non-zero 'scrolloff' value
command('set scrolloff=1')
eq(10, screenrow())
scroll('up')
eq(10, screenrow())
scroll('down')
eq(10, screenrow())
-- also in insert mode
feed('i')
eq(10, screenrow())
scroll('up')
eq(10, screenrow())
scroll('down')
eq(10, screenrow())
end)
local test_vertical_scrolling = function()