aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/autocmd.c
diff options
context:
space:
mode:
authorSean Dewar <6256228+seandewar@users.noreply.github.com>2024-02-26 14:51:31 +0000
committerSean Dewar <6256228+seandewar@users.noreply.github.com>2024-03-08 23:24:05 +0000
commitd942c2b9432d81e4b509519bd48fa886e37e9ca8 (patch)
treee4318cabfd0461854051794ce2e903eb5dbcbe80 /src/nvim/autocmd.c
parent832bc5c169d8b339ef139ef0bdcefb2e72864e6e (diff)
downloadrneovim-d942c2b9432d81e4b509519bd48fa886e37e9ca8.tar.gz
rneovim-d942c2b9432d81e4b509519bd48fa886e37e9ca8.tar.bz2
rneovim-d942c2b9432d81e4b509519bd48fa886e37e9ca8.zip
fix(api): handle win_split_ins failure properly
Problem: nvim_win_set_config does not handle failure in win_split_ins properly yet, which can cause all sorts of issues. Also nvim_open_win and nvim_win_set_config do not set the error message to the one from win_split_ins. Solution: handle failure by undoing winframe_remove, like in win_splitmove. Make sure autocommands from switching to the altwin fire within a valid window, and ensure they don't screw things up. Set the error message to that of win_split_ins, if any. Also change a few other small things, including: - adjust win_append to take a tabpage_T * argument, which is more consistent with win_remove (and also allows us to undo a call to win_remove). - allow winframe_restore to restore window positions. Useful if `wp` was in a different tabpage, as a call to win_comp_pos (which only works for the current tabpage) after winframe_restore should no longer be needed. Though enter_tabpage calls win_comp_pos anyway, this has the advantage of ensuring w_winrow/col remains accurate even before entering the tabpage (useful for stuff like win_screenpos, if used on a window in another tabpage). (This change should probably also be PR'd to Vim later, even though it doesn't use winframe_restore for a `wp` in a different tabpage yet).
Diffstat (limited to 'src/nvim/autocmd.c')
-rw-r--r--src/nvim/autocmd.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index 3f93906942..652b6ba74e 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -1333,7 +1333,7 @@ void aucmd_prepbuf(aco_save_T *aco, buf_T *buf)
block_autocmds(); // We don't want BufEnter/WinEnter autocommands.
if (need_append) {
- win_append(lastwin, auc_win);
+ win_append(lastwin, auc_win, NULL);
pmap_put(int)(&window_handles, auc_win->handle, auc_win);
win_config_float(auc_win, auc_win->w_config);
}