mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.0652: 'smoothscroll' not tested with 'number' and "n" in 'cpo'
Problem: 'smoothscroll' not tested with 'number' and "n" in 'cpo'.
Solution: Add tests, fix uncovered problem.
b6aab8f44b
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
e9b1df21bc
commit
f3b44cf23d
@ -596,7 +596,8 @@ static void handle_lnum_col(win_T *wp, winlinevars_T *wlv, int num_signs, int si
|
||||
int sign_num_attr, int sign_cul_attr)
|
||||
{
|
||||
if ((wp->w_p_nu || wp->w_p_rnu)
|
||||
&& (wlv->row == wlv->startrow + wlv->filler_lines
|
||||
&& ((wlv->row == wlv->startrow + wlv->filler_lines
|
||||
&& (wp->w_skipcol == 0 || wlv->row > wp->w_winrow))
|
||||
|| vim_strchr(p_cpo, CPO_NUMCOL) == NULL)) {
|
||||
// If 'signcolumn' is set to 'number' and a sign is present
|
||||
// in "lnum", then display the sign instead of the line
|
||||
|
@ -1447,6 +1447,26 @@ static void win_update(win_T *wp, DecorProviders *providers)
|
||||
|
||||
init_search_hl(wp, &screen_search_hl);
|
||||
|
||||
// Make sure skipcol is valid, it depends on various options and the window
|
||||
// width.
|
||||
if (wp->w_skipcol > 0) {
|
||||
int w = 0;
|
||||
int width1 = wp->w_width - win_col_off(wp);
|
||||
int width2 = width1 + win_col_off2(wp);
|
||||
int add = width1;
|
||||
|
||||
while (w < wp->w_skipcol) {
|
||||
if (w > 0) {
|
||||
add = width2;
|
||||
}
|
||||
w += add;
|
||||
}
|
||||
if (w != wp->w_skipcol) {
|
||||
// always round down, the higher value may not be valid
|
||||
wp->w_skipcol = w - add;
|
||||
}
|
||||
}
|
||||
|
||||
// Force redraw when width of 'number' or 'relativenumber' column
|
||||
// changes.
|
||||
int nrwidth = (wp->w_p_nu || wp->w_p_rnu || *wp->w_p_stc) ? number_width(wp) : 0;
|
||||
|
@ -173,4 +173,103 @@ describe('smoothscroll', function()
|
||||
feed('<C-Y>')
|
||||
screen:expect(s8)
|
||||
end)
|
||||
|
||||
-- oldtest: Test_smoothscroll_number()
|
||||
it("works 'number' and 'cpo'+=n", function()
|
||||
exec([[
|
||||
call setline(1, [ 'one ' .. 'word '->repeat(20), 'two ' .. 'long word '->repeat(7), 'line', 'line', 'line', ])
|
||||
set smoothscroll scrolloff=5
|
||||
set number cpo+=n
|
||||
:3
|
||||
]])
|
||||
screen:expect([[
|
||||
1 one word word word word word word wo|
|
||||
rd word word word word word word word wo|
|
||||
rd word word word word word |
|
||||
2 two long word long word long word lo|
|
||||
ng word long word long word long word |
|
||||
3 ^line |
|
||||
4 line |
|
||||
5 line |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
|
|
||||
]])
|
||||
feed('<C-E>')
|
||||
screen:expect([[
|
||||
<<<word word word word word word word wo|
|
||||
rd word word word word word |
|
||||
2 two long word long word long word lo|
|
||||
ng word long word long word long word |
|
||||
3 ^line |
|
||||
4 line |
|
||||
5 line |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
|
|
||||
]])
|
||||
feed('<C-E>')
|
||||
screen:expect([[
|
||||
<<<word word word word word |
|
||||
2 two long word long word long word lo|
|
||||
ng word long word long word long word |
|
||||
3 ^line |
|
||||
4 line |
|
||||
5 line |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
|
|
||||
]])
|
||||
exec('set cpo-=n')
|
||||
screen:expect([[
|
||||
<<< d word word word word word word |
|
||||
2 two long word long word long word lo|
|
||||
ng word long word long word long wor|
|
||||
d |
|
||||
3 ^line |
|
||||
4 line |
|
||||
5 line |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
|
|
||||
]])
|
||||
feed('<C-Y>')
|
||||
screen:expect([[
|
||||
<<< rd word word word word word word wor|
|
||||
d word word word word word word |
|
||||
2 two long word long word long word lo|
|
||||
ng word long word long word long wor|
|
||||
d |
|
||||
3 ^line |
|
||||
4 line |
|
||||
5 line |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
|
|
||||
]])
|
||||
feed('<C-Y>')
|
||||
screen:expect([[
|
||||
1 one word word word word word word wo|
|
||||
rd word word word word word word wor|
|
||||
d word word word word word word |
|
||||
2 two long word long word long word lo|
|
||||
ng word long word long word long wor|
|
||||
d |
|
||||
3 ^line |
|
||||
4 line |
|
||||
5 line |
|
||||
~ |
|
||||
~ |
|
||||
|
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
@ -704,7 +704,7 @@ describe("'listchars' highlight", function()
|
||||
feed_command('set listchars=eol:¬,precedes:< list')
|
||||
feed('90ia<esc>')
|
||||
screen:expect([[
|
||||
{0:<}aaaaaaaaaaaaaaaaaaa|
|
||||
{0:<<<}aaaaaaaaaaaaaaaaa|
|
||||
aaaaaaaaaaaaaaaaaaaa|
|
||||
aaaaaaaaaaaaaaaaaaaa|
|
||||
aaaaaaaaa^a{0:¬} |
|
||||
|
@ -2396,7 +2396,7 @@ describe('builtin popupmenu', function()
|
||||
-- can't draw the pum, but check we don't crash
|
||||
screen:try_resize(12,2)
|
||||
screen:expect([[
|
||||
text^ |
|
||||
{1:<<<}t^ |
|
||||
{2:-- INSERT -} |
|
||||
]])
|
||||
|
||||
|
@ -123,6 +123,41 @@ func Test_smoothscroll_CtrlE_CtrlY()
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
func Test_smoothscroll_number()
|
||||
CheckScreendump
|
||||
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
setline(1, [
|
||||
'one ' .. 'word '->repeat(20),
|
||||
'two ' .. 'long word '->repeat(7),
|
||||
'line',
|
||||
'line',
|
||||
'line',
|
||||
])
|
||||
set smoothscroll
|
||||
set number cpo+=n
|
||||
:3
|
||||
END
|
||||
call writefile(lines, 'XSmoothNumber', 'D')
|
||||
let buf = RunVimInTerminal('-S XSmoothNumber', #{rows: 12, cols: 40})
|
||||
|
||||
call VerifyScreenDump(buf, 'Test_smooth_number_1', {})
|
||||
call term_sendkeys(buf, "\<C-E>")
|
||||
call VerifyScreenDump(buf, 'Test_smooth_number_2', {})
|
||||
call term_sendkeys(buf, "\<C-E>")
|
||||
call VerifyScreenDump(buf, 'Test_smooth_number_3', {})
|
||||
|
||||
call term_sendkeys(buf, ":set cpo-=n\<CR>")
|
||||
call VerifyScreenDump(buf, 'Test_smooth_number_4', {})
|
||||
call term_sendkeys(buf, "\<C-Y>")
|
||||
call VerifyScreenDump(buf, 'Test_smooth_number_5', {})
|
||||
call term_sendkeys(buf, "\<C-Y>")
|
||||
call VerifyScreenDump(buf, 'Test_smooth_number_6', {})
|
||||
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Loading…
Reference in New Issue
Block a user