Skip to content

Commit

Permalink
fix(win_split_ins): do not fail when oldwin is not valid
Browse files Browse the repository at this point in the history
Ref #14240
  • Loading branch information
zeertzjq committed Mar 13, 2022
1 parent d33aebb commit 0cf2dc6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
9 changes: 0 additions & 9 deletions src/nvim/quickfix.c
Original file line number Diff line number Diff line change
Expand Up @@ -3646,15 +3646,6 @@ static int qf_open_new_cwindow(qf_info_T *qi, int height)
if (win_split(height, flags) == FAIL) {
return FAIL; // not enough room for window
}

// User autocommands may have invalidated the previous window after calling
// win_split, so add a check to ensure that the win is still here
if (IS_LL_STACK(qi) && !win_valid(win)) {
// close the window that was supposed to be for the loclist
win_close(curwin, false, false);
return FAIL;
}

RESET_BINDING(curwin);

if (IS_LL_STACK(qi)) {
Expand Down
8 changes: 3 additions & 5 deletions src/nvim/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -1420,13 +1420,11 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
p_wh = i;
}

if (!win_valid(oldwin)) {
return FAIL;
if (win_valid(oldwin)) {
// Send the window positions to the UI
oldwin->w_pos_changed = true;
}

// Send the window positions to the UI
oldwin->w_pos_changed = true;

return OK;
}

Expand Down

0 comments on commit 0cf2dc6

Please sign in to comment.