Mercurial > vim
comparison src/mouse.c @ 29841:b37b74ea8dee v9.0.0259
patch 9.0.0259: crash with mouse click when not initialized
Commit: https://github.com/vim/vim/commit/80525751c5ce9ed82c41d83faf9ef38667bf61b1
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 24 19:27:45 2022 +0100
patch 9.0.0259: crash with mouse click when not initialized
Problem: Crash with mouse click when not initialized.
Solution: Check TabPageIdxs[] is not NULL.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 24 Aug 2022 20:30:03 +0200 |
parents | 89e1d67814a9 |
children | 101f08b49ed3 |
comparison
equal
deleted
inserted
replaced
29840:b15334beeaa4 | 29841:b37b74ea8dee |
---|---|
469 if (!is_click) | 469 if (!is_click) |
470 jump_flags |= MOUSE_FOCUS | MOUSE_DID_MOVE; | 470 jump_flags |= MOUSE_FOCUS | MOUSE_DID_MOVE; |
471 | 471 |
472 start_visual.lnum = 0; | 472 start_visual.lnum = 0; |
473 | 473 |
474 // Check for clicking in the tab page line. | 474 if (TabPageIdxs != NULL) // only when initialized |
475 if (mouse_row == 0 && firstwin->w_winrow > 0) | 475 { |
476 { | 476 // Check for clicking in the tab page line. |
477 if (is_drag) | 477 if (mouse_row == 0 && firstwin->w_winrow > 0) |
478 { | 478 { |
479 if (in_tab_line) | 479 if (is_drag) |
480 { | 480 { |
481 if (in_tab_line) | |
482 { | |
483 c1 = TabPageIdxs[mouse_col]; | |
484 tabpage_move(c1 <= 0 ? 9999 : c1 < tabpage_index(curtab) | |
485 ? c1 - 1 : c1); | |
486 } | |
487 return FALSE; | |
488 } | |
489 | |
490 // click in a tab selects that tab page | |
491 if (is_click | |
492 # ifdef FEAT_CMDWIN | |
493 && cmdwin_type == 0 | |
494 # endif | |
495 && mouse_col < Columns) | |
496 { | |
497 in_tab_line = TRUE; | |
481 c1 = TabPageIdxs[mouse_col]; | 498 c1 = TabPageIdxs[mouse_col]; |
482 tabpage_move(c1 <= 0 ? 9999 : c1 < tabpage_index(curtab) | 499 if (c1 >= 0) |
483 ? c1 - 1 : c1); | |
484 } | |
485 return FALSE; | |
486 } | |
487 | |
488 // click in a tab selects that tab page | |
489 if (is_click | |
490 # ifdef FEAT_CMDWIN | |
491 && cmdwin_type == 0 | |
492 # endif | |
493 && mouse_col < Columns) | |
494 { | |
495 in_tab_line = TRUE; | |
496 c1 = TabPageIdxs[mouse_col]; | |
497 if (c1 >= 0) | |
498 { | |
499 if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK) | |
500 { | 500 { |
501 // double click opens new page | 501 if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK) |
502 end_visual_mode_keep_button(); | 502 { |
503 tabpage_new(); | 503 // double click opens new page |
504 tabpage_move(c1 == 0 ? 9999 : c1 - 1); | 504 end_visual_mode_keep_button(); |
505 tabpage_new(); | |
506 tabpage_move(c1 == 0 ? 9999 : c1 - 1); | |
507 } | |
508 else | |
509 { | |
510 // Go to specified tab page, or next one if not clicking | |
511 // on a label. | |
512 goto_tabpage(c1); | |
513 | |
514 // It's like clicking on the status line of a window. | |
515 if (curwin != old_curwin) | |
516 end_visual_mode_keep_button(); | |
517 } | |
505 } | 518 } |
506 else | 519 else |
507 { | 520 { |
508 // Go to specified tab page, or next one if not clicking | 521 tabpage_T *tp; |
509 // on a label. | 522 |
510 goto_tabpage(c1); | 523 // Close the current or specified tab page. |
511 | 524 if (c1 == -999) |
512 // It's like clicking on the status line of a window. | 525 tp = curtab; |
513 if (curwin != old_curwin) | 526 else |
514 end_visual_mode_keep_button(); | 527 tp = find_tabpage(-c1); |
528 if (tp == curtab) | |
529 { | |
530 if (first_tabpage->tp_next != NULL) | |
531 tabpage_close(FALSE); | |
532 } | |
533 else if (tp != NULL) | |
534 tabpage_close_other(tp, FALSE); | |
515 } | 535 } |
516 } | 536 } |
517 else | 537 return TRUE; |
518 { | 538 } |
519 tabpage_T *tp; | 539 else if (is_drag && in_tab_line) |
520 | 540 { |
521 // Close the current or specified tab page. | 541 c1 = TabPageIdxs[mouse_col]; |
522 if (c1 == -999) | 542 tabpage_move(c1 <= 0 ? 9999 : c1 - 1); |
523 tp = curtab; | 543 return FALSE; |
524 else | 544 } |
525 tp = find_tabpage(-c1); | |
526 if (tp == curtab) | |
527 { | |
528 if (first_tabpage->tp_next != NULL) | |
529 tabpage_close(FALSE); | |
530 } | |
531 else if (tp != NULL) | |
532 tabpage_close_other(tp, FALSE); | |
533 } | |
534 } | |
535 return TRUE; | |
536 } | |
537 else if (is_drag && in_tab_line) | |
538 { | |
539 c1 = TabPageIdxs[mouse_col]; | |
540 tabpage_move(c1 <= 0 ? 9999 : c1 - 1); | |
541 return FALSE; | |
542 } | 545 } |
543 | 546 |
544 // When 'mousemodel' is "popup" or "popup_setpos", translate mouse events: | 547 // When 'mousemodel' is "popup" or "popup_setpos", translate mouse events: |
545 // right button up -> pop-up menu | 548 // right button up -> pop-up menu |
546 // shift-left button -> right button | 549 // shift-left button -> right button |