vim-patch:9.1.0730: Crash with cursor-screenline and narrow window

Problem:  Crash with cursor-screenline and narrow window
          (elig0n)
Solution: Don't set right_col when width2 is 0 (zeertzjq).

fixes: vim/vim#15677
closes: vim/vim#15678

59149f0269
This commit is contained in:
zeertzjq 2024-09-14 19:28:13 +08:00
parent 90585e47fe
commit 5191a11d66
2 changed files with 13 additions and 3 deletions

View File

@ -189,7 +189,7 @@ static void margin_columns_win(win_T *wp, int *left_col, int *right_col)
*left_col = 0;
*right_col = width1;
if (wp->w_virtcol >= (colnr_T)width1) {
if (wp->w_virtcol >= (colnr_T)width1 && width2 > 0) {
*right_col = width1 + ((wp->w_virtcol - width1) / width2 + 1) * width2;
}
if (wp->w_virtcol >= (colnr_T)width1 && width2 > 0) {

View File

@ -300,7 +300,7 @@ func Test_cursorline_screenline_update()
set cursorline cursorlineopt=screenline
inoremap <F2> <Cmd>call cursor(1, 1)<CR>
END
call writefile(lines, 'Xcul_screenline')
call writefile(lines, 'Xcul_screenline', 'D')
let buf = RunVimInTerminal('-S Xcul_screenline', #{rows: 8})
call term_sendkeys(buf, "A")
@ -310,7 +310,17 @@ func Test_cursorline_screenline_update()
call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf)
call delete('Xcul_screenline')
endfunc
func Test_cursorline_screenline_zero_width()
CheckOption foldcolumn
set cursorline culopt=screenline winminwidth=1 foldcolumn=1
" This used to crash Vim
1vnew | redraw
bwipe!
set cursorline& culopt& winminwidth& foldcolumn&
endfunc
func Test_cursorline_cursorbind_horizontal_scroll()