Mercurial > vim
comparison src/window.c @ 34063:808cf14bad77 v9.1.0001
patch 9.1.0001: when closing window, wincmd p may fail
Commit: https://github.com/vim/vim/commit/bf44b69d1f91d9778ae1887128c63d35d9a3d19b
Author: Sean Dewar <seandewar@users.noreply.github.com>
Date: Wed Jan 3 18:52:52 2024 +0100
patch 9.1.0001: when closing window, wincmd p may fail
Avoid `prevwin == curwin` when closing `curwin`
Problem: When closing the current window (or when moving it to a tabpage), the
previous window may refer to the new current window
(`winnr() == winnr('#')`) if that window is selected as the
new current window.
Solution: Set `prevwin = NULL` when switching away from an invalid `curwin` and
the target window was the `prevwin`.
(Sean Dewar)
related: #4537
closes: #13762
Signed-off-by: Sean Dewar <seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 03 Jan 2024 19:15:03 +0100 |
parents | f4d88db48a63 |
children | 0c40b031e7d8 |
comparison
equal
deleted
inserted
replaced
34062:65ef35dd18b6 | 34063:808cf14bad77 |
---|---|
5379 update_topline(); | 5379 update_topline(); |
5380 | 5380 |
5381 // may have to copy the buffer options when 'cpo' contains 'S' | 5381 // may have to copy the buffer options when 'cpo' contains 'S' |
5382 if (wp->w_buffer != curbuf) | 5382 if (wp->w_buffer != curbuf) |
5383 buf_copy_options(wp->w_buffer, BCO_ENTER | BCO_NOHELP); | 5383 buf_copy_options(wp->w_buffer, BCO_ENTER | BCO_NOHELP); |
5384 | |
5384 if (curwin_invalid == 0) | 5385 if (curwin_invalid == 0) |
5385 { | 5386 { |
5386 prevwin = curwin; // remember for CTRL-W p | 5387 prevwin = curwin; // remember for CTRL-W p |
5387 curwin->w_redr_status = TRUE; | 5388 curwin->w_redr_status = TRUE; |
5388 } | 5389 } |
5390 else if (wp == prevwin) | |
5391 prevwin = NULL; // don't want it to be the new curwin | |
5392 | |
5389 curwin = wp; | 5393 curwin = wp; |
5390 curbuf = wp->w_buffer; | 5394 curbuf = wp->w_buffer; |
5391 check_cursor(); | 5395 check_cursor(); |
5392 if (!virtual_active()) | 5396 if (!virtual_active()) |
5393 curwin->w_cursor.coladd = 0; | 5397 curwin->w_cursor.coladd = 0; |