vim-patch:9.0.0259: crash with mouse click when not initialized (#21282)

Problem:    Crash with mouse click when not initialized.
Solution:   Check TabPageIdxs[] is not NULL.

80525751c5

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2022-12-04 17:44:51 +08:00
committed by GitHub
parent 823247a040
commit 9263f17d0d
2 changed files with 73 additions and 57 deletions

View File

@@ -467,6 +467,7 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
start_visual.lnum = 0;
if (tab_page_click_defs != NULL) { // only when initialized
// Check for clicking in the tab page line.
if (mouse_grid <= 1 && mouse_row == 0 && firstwin->w_winrow > 0) {
if (is_drag) {
@@ -528,6 +529,7 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
move_tab_to_mouse();
return false;
}
}
// When 'mousemodel' is "popup" or "popup_setpos", translate mouse events:
// right button up -> pop-up menu

View File

@@ -147,4 +147,18 @@ func Test_tabline_20_format_items_no_overrun()
set showtabline& tabline&
endfunc
func Test_mouse_click_in_tab()
" This used to crash because TabPageIdxs[] was not initialized
let lines =<< trim END
tabnew
set mouse=a
exe "norm \<LeftMouse>"
END
call writefile(lines, 'Xclickscript')
call RunVim([], [], "-e -s -S Xclickscript -c qa")
call delete('Xclickscript')
endfunc
" vim: shiftwidth=2 sts=2 expandtab