mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
fix(options): fix local 'sidescrolloff' doesn't work for mouse (#21162)
Missing part of Vim patch 8.1.0864.
This commit is contained in:
@@ -456,12 +456,13 @@ bool leftcol_changed(void)
|
|||||||
|
|
||||||
// If the cursor is right or left of the screen, move it to last or first
|
// If the cursor is right or left of the screen, move it to last or first
|
||||||
// character.
|
// character.
|
||||||
if (curwin->w_virtcol > (colnr_T)(lastcol - p_siso)) {
|
long siso = get_sidescrolloff_value(curwin);
|
||||||
|
if (curwin->w_virtcol > (colnr_T)(lastcol - siso)) {
|
||||||
retval = true;
|
retval = true;
|
||||||
coladvance((colnr_T)(lastcol - p_siso));
|
coladvance((colnr_T)(lastcol - siso));
|
||||||
} else if (curwin->w_virtcol < curwin->w_leftcol + p_siso) {
|
} else if (curwin->w_virtcol < curwin->w_leftcol + siso) {
|
||||||
retval = true;
|
retval = true;
|
||||||
coladvance((colnr_T)(curwin->w_leftcol + p_siso));
|
coladvance((colnr_T)(curwin->w_leftcol + siso));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the start of the character under the cursor is not on the screen,
|
// If the start of the character under the cursor is not on the screen,
|
||||||
|
@@ -2768,7 +2768,7 @@ static void nv_zet(cmdarg_T *cap)
|
|||||||
long old_fdl = curwin->w_p_fdl;
|
long old_fdl = curwin->w_p_fdl;
|
||||||
int old_fen = curwin->w_p_fen;
|
int old_fen = curwin->w_p_fen;
|
||||||
|
|
||||||
int l_p_siso = (int)get_sidescrolloff_value(curwin);
|
int siso = (int)get_sidescrolloff_value(curwin);
|
||||||
|
|
||||||
if (ascii_isdigit(nchar) && !nv_z_get_count(cap, &nchar)) {
|
if (ascii_isdigit(nchar) && !nv_z_get_count(cap, &nchar)) {
|
||||||
return;
|
return;
|
||||||
@@ -2898,8 +2898,8 @@ static void nv_zet(cmdarg_T *cap)
|
|||||||
} else {
|
} else {
|
||||||
getvcol(curwin, &curwin->w_cursor, &col, NULL, NULL);
|
getvcol(curwin, &curwin->w_cursor, &col, NULL, NULL);
|
||||||
}
|
}
|
||||||
if (col > l_p_siso) {
|
if (col > siso) {
|
||||||
col -= l_p_siso;
|
col -= siso;
|
||||||
} else {
|
} else {
|
||||||
col = 0;
|
col = 0;
|
||||||
}
|
}
|
||||||
@@ -2919,10 +2919,10 @@ static void nv_zet(cmdarg_T *cap)
|
|||||||
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);
|
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);
|
||||||
}
|
}
|
||||||
n = curwin->w_width_inner - curwin_col_off();
|
n = curwin->w_width_inner - curwin_col_off();
|
||||||
if (col + l_p_siso < n) {
|
if (col + siso < n) {
|
||||||
col = 0;
|
col = 0;
|
||||||
} else {
|
} else {
|
||||||
col = col + l_p_siso - n + 1;
|
col = col + siso - n + 1;
|
||||||
}
|
}
|
||||||
if (curwin->w_leftcol != col) {
|
if (curwin->w_leftcol != col) {
|
||||||
curwin->w_leftcol = col;
|
curwin->w_leftcol = col;
|
||||||
|
@@ -968,6 +968,49 @@ describe('ui/mouse/input', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("'sidescrolloff' applies to horizontal scrolling", function()
|
||||||
|
command('set nowrap')
|
||||||
|
command('set sidescrolloff=4')
|
||||||
|
|
||||||
|
feed("I <esc>020ib<esc>0")
|
||||||
|
screen:expect([[
|
||||||
|
testing |
|
||||||
|
mouse |
|
||||||
|
^bbbbbbbbbbbbbbbbbbbb supp|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
meths.input_mouse('wheel', 'right', '', 0, 0, 27)
|
||||||
|
screen:expect([[
|
||||||
|
g |
|
||||||
|
|
|
||||||
|
bbbb^bbbbbbbbbb support an|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
-- window-local 'sidescrolloff' should override global value. #21162
|
||||||
|
command('setlocal sidescrolloff=2')
|
||||||
|
feed('0')
|
||||||
|
screen:expect([[
|
||||||
|
testing |
|
||||||
|
mouse |
|
||||||
|
^bbbbbbbbbbbbbbbbbbbb supp|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
meths.input_mouse('wheel', 'right', '', 0, 0, 27)
|
||||||
|
screen:expect([[
|
||||||
|
g |
|
||||||
|
|
|
||||||
|
bb^bbbbbbbbbbbb support an|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
describe('on concealed text', function()
|
describe('on concealed text', function()
|
||||||
-- Helpful for reading the test expectations:
|
-- Helpful for reading the test expectations:
|
||||||
-- :match Error /\^/
|
-- :match Error /\^/
|
||||||
|
Reference in New Issue
Block a user