diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-05 17:22:14 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-05 17:42:49 -0400 |
commit | e7e2115de5c1a4bafdf8b0819f97a0bea8de379b (patch) | |
tree | 08b0639f219df7051487bed7c8fcc35c20d1d6dc | |
parent | fe6e4b3244c8e42af2fb74e5ee73392a2e16480d (diff) | |
download | rneovim-e7e2115de5c1a4bafdf8b0819f97a0bea8de379b.tar.gz rneovim-e7e2115de5c1a4bafdf8b0819f97a0bea8de379b.tar.bz2 rneovim-e7e2115de5c1a4bafdf8b0819f97a0bea8de379b.zip |
vim-patch:8.0.0948: crash if timer closes window while dragging status line
Problem: Crash if timer closes window while dragging status line.
Solution: Check if the window still exists. (Yasuhiro Matsumoto, closes
vim/vim#1979)
https://github.com/vim/vim/commit/989a70c590c2bd109eb362d3a0e48cb1427ae13d
-rw-r--r-- | src/nvim/edit.c | 6 | ||||
-rw-r--r-- | src/nvim/eval.c | 3 | ||||
-rw-r--r-- | src/nvim/mouse.c | 13 | ||||
-rw-r--r-- | src/nvim/normal.c | 6 |
4 files changed, 25 insertions, 3 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index cdccb57eee..4e4ca1f8f3 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -7884,7 +7884,11 @@ static void ins_mousescroll(int dir) col = mouse_col; /* find the window at the pointer coordinates */ - curwin = mouse_find_win(&row, &col); + win_T *const wp = mouse_find_win(&row, &col); + if (wp == NULL) { + return; + } + curwin = wp; curbuf = curwin->w_buffer; } if (curwin == old_curwin) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 15b5c3eef3..3abc39e7bf 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -9493,6 +9493,9 @@ static void f_getchar(typval_T *argvars, typval_T *rettv, FunPtr fptr) /* Find the window at the mouse coordinates and compute the * text position. */ win = mouse_find_win(&row, &col); + if (win == NULL) { + return; + } (void)mouse_comp_pos(win, &row, &col, &lnum); for (wp = firstwin; wp != win; wp = wp->w_next) ++winnr; diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index 8c615f52e7..3c792326a4 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -125,6 +125,9 @@ retnomove: // find the window where the row is in wp = mouse_find_win(&row, &col); + if (wp == NULL) { + return IN_UNKNOWN; + } dragwin = NULL; // winpos and height may change in win_enter()! if (row >= wp->w_height) { // In (or below) status line @@ -427,6 +430,7 @@ bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump) // Find the window at screen position "*rowp" and "*colp". The positions are // updated to become relative to the top-left of the window. +// Returns NULL when something is wrong. win_T *mouse_find_win(int *rowp, int *colp) { frame_T *fp; @@ -450,7 +454,14 @@ win_T *mouse_find_win(int *rowp, int *colp) } } } - return fp->fr_win; + // When using a timer that closes a window the window might not actually + // exist. + FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { + if (wp == fp->fr_win) { + return wp; + } + } + return NULL; } /* diff --git a/src/nvim/normal.c b/src/nvim/normal.c index a695620801..001972103c 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3995,7 +3995,11 @@ static void nv_mousescroll(cmdarg_T *cap) col = mouse_col; /* find the window at the pointer coordinates */ - curwin = mouse_find_win(&row, &col); + win_T *const wp = mouse_find_win(&row, &col); + if (wp == NULL) { + return; + } + curwin = wp; curbuf = curwin->w_buffer; } |