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
This commit is contained in:
Justin M. Keyes
2019-11-29 23:48:14 -08:00
committed by GitHub
parent 1f684cf80a
commit f6e7857c54
4 changed files with 38 additions and 6 deletions

View File

@@ -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);
}