aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-11-29 23:48:14 -0800
committerGitHub <noreply@github.com>2019-11-29 23:48:14 -0800
commitf6e7857c54a015cdfac9ce65ec0b65d65d590aeb (patch)
tree88aec7943072ce57536f4a7b26af627601d29817 /src
parent1f684cf80a0026848f5d64794dfca05654a9f66a (diff)
downloadrneovim-f6e7857c54a015cdfac9ce65ec0b65d65d590aeb.tar.gz
rneovim-f6e7857c54a015cdfac9ce65ec0b65d65d590aeb.tar.bz2
rneovim-f6e7857c54a015cdfac9ce65ec0b65d65d590aeb.zip
floatwin: show error if window is closed immediately #11476
Autocmds may close window while it is being entered, then win_set_minimal_style(wp) operates on an invalid pointer. We could silently ignore this instead, but it is unlikely to be intentional, so it is more useful to show an error. fix #11383
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/vim.c4
-rw-r--r--src/nvim/window.c7
2 files changed, 8 insertions, 3 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 9adc61b843..e4a9bd64ff 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -1096,6 +1096,10 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dictionary config,
if (enter) {
win_enter(wp, false);
}
+ if (!win_valid(wp)) {
+ api_set_error(err, kErrorTypeException, "Window was closed immediately");
+ return 0;
+ }
if (buffer > 0) {
nvim_win_set_buf(wp->handle, buffer, err);
}
diff --git a/src/nvim/window.c b/src/nvim/window.c
index dee36df433..76fc36607c 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -4372,9 +4372,10 @@ static void win_goto_hor(bool left, long count)
}
}
-/*
- * Make window "wp" the current window.
- */
+/// Make window `wp` the current window.
+///
+/// @warning Autocmds may close the window immediately, so caller must check
+/// win_valid(wp).
void win_enter(win_T *wp, bool undo_sync)
{
win_enter_ext(wp, undo_sync, false, false, true, true);