[vim/vim] fix(quickfix): restore correct window when closing quickfix (PR #18961)

8 views
Skip to first unread message

glepnir

unread,
Dec 18, 2025, 4:50:59 AM (19 hours ago) Dec 18
to vim/vim, Subscribed

Problem:
After botright copen and close this quikfix window, cursor ends up in the wrong window. The problem is fr_child always points to the first (leftmost for FR_ROW, topmost for FR_COL) child frame. When do :vsplit, the new window is created on the left, and frame_insert() updates the parent's fr_child to point to this new left window.

Solution:
Same as help windows - snapshot before open, restore when close.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/18961

Commit Summary

  • 8e40940 fix(quickfix): restore correct window when closing quickfix

File Changes

(5 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18961@github.com>

h_east

unread,
Dec 18, 2025, 9:43:14 AM (14 hours ago) Dec 18
to vim/vim, Subscribed

@h-east commented on this pull request.


In src/window.c:

> @@ -2740,6 +2746,11 @@ win_close(win_T *win, int free_buf)
     else
 	clear_snapshot(curtab, SNAP_HELP_IDX);
 
+    if (bt_quickfix(win->w_buffer))
+	quickfix_window = true;

TRUE/FALSE for int type. true/false for bool type.

⬇️ Suggested change
-	quickfix_window = true;
+	quickfix_window = TRUE;


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18961/review/3593348916@github.com>

Yegappan Lakshmanan

unread,
Dec 18, 2025, 10:19:35 AM (14 hours ago) Dec 18
to vim/vim, Subscribed

@yegappan commented on this pull request.


In src/testdir/test_quickfix.vim:

> @@ -6958,4 +6958,16 @@ func Test_vimgrep_dummy_buffer_keep()
   %bw!
 endfunc
 
+func Test_quickfix_restore_current_win()
+  let curwin = win_getid()
+  vsplit b
+  wincmd p
+  botright copen
+  cclose
+
+  call assert_true(curwin == win_getid())

Can you use call assert_equal(curwin, win_getid()) instead? When a test fails, assert_equal() will emit the expected value and the actual value but assert_true() will not do that. This is useful in debugging tests that are failing.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18961/review/3593545285@github.com>

Yegappan Lakshmanan

unread,
Dec 18, 2025, 10:19:58 AM (14 hours ago) Dec 18
to vim/vim, Subscribed

@yegappan commented on this pull request.


In src/testdir/test_quickfix.vim:

> @@ -6958,4 +6958,16 @@ func Test_vimgrep_dummy_buffer_keep()
   %bw!
 endfunc
 
+func Test_quickfix_restore_current_win()
+  let curwin = win_getid()
+  vsplit b
+  wincmd p
+  botright copen
+  cclose
+
+  call assert_true(curwin == win_getid())
+  wincmd w

Is jumping to another window needed here?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18961/review/3593547257@github.com>

glepnir

unread,
Dec 18, 2025, 10:46:22 PM (1 hour ago) Dec 18
to vim/vim, Push

@glepnir pushed 1 commit.

  • b0e8b61 fix(quickfix): restore correct window when closing quickfix


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18961/before/422ba592a86272f03e491664fdb8b0123c36fa58/after/b0e8b61c9bcd77fab77a2db5c4b950de9e6fa568@github.com>

zeertzjq

unread,
Dec 18, 2025, 10:54:06 PM (1 hour ago) Dec 18
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In src/testdir/test_quickfix.vim:

> @@ -6958,4 +6958,15 @@ func Test_vimgrep_dummy_buffer_keep()
   %bw!
 endfunc
 
+func Test_quickfix_restore_current_win()
+  let curwin = win_getid()
+  vsplit b
+  wincmd p
+  botright copen
+  cclose
+
+  call assert_equal(1, curwin == win_getid())
⬇️ Suggested change
-  call assert_equal(1, curwin == win_getid())
+  call assert_equal(curwin, win_getid())


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18961/review/3596701851@github.com>

glepnir

unread,
Dec 18, 2025, 10:54:56 PM (1 hour ago) Dec 18
to vim/vim, Push

@glepnir pushed 1 commit.

  • aa281b1 fix(quickfix): restore correct window when closing quickfix

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18961/before/b0e8b61c9bcd77fab77a2db5c4b950de9e6fa568/after/aa281b1a2c06566afad5fb857bf35bb69ed9f53d@github.com>

zeertzjq

unread,
Dec 18, 2025, 10:59:51 PM (1 hour ago) Dec 18
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In src/testdir/test_quickfix.vim:

> @@ -6958,4 +6958,15 @@ func Test_vimgrep_dummy_buffer_keep()
   %bw!
 endfunc
 
+func Test_quickfix_restore_current_win()
+  let curwin = win_getid()
+  vsplit b

Having a single-character buffer name is a bit strange.

⬇️ Suggested change
-  vsplit b
+  vsplit Xb

In src/testdir/test_quickfix.vim:

> @@ -6958,4 +6958,15 @@ func Test_vimgrep_dummy_buffer_keep()
   %bw!
 endfunc
 
+func Test_quickfix_restore_current_win()
+  let curwin = win_getid()
+  vsplit b
+  wincmd p
+  botright copen
+  cclose
+
+  call assert_equal(curwin, win_getid())
+  only
⬇️ Suggested change
-  only
+  bw! Xb


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18961/review/3596706740@github.com>

glepnir

unread,
Dec 18, 2025, 11:07:04 PM (1 hour ago) Dec 18
to vim/vim, Subscribed

@glepnir commented on this pull request.


In src/testdir/test_quickfix.vim:

> @@ -6958,4 +6958,15 @@ func Test_vimgrep_dummy_buffer_keep()
   %bw!
 endfunc
 
+func Test_quickfix_restore_current_win()
+  let curwin = win_getid()
+  vsplit b

okay


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18961/review/3596717153@github.com>

glepnir

unread,
Dec 18, 2025, 11:07:45 PM (1 hour ago) Dec 18
to vim/vim, Push

@glepnir pushed 1 commit.

  • 3a65c4a fix(quickfix): restore correct window when closing quickfix

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18961/before/aa281b1a2c06566afad5fb857bf35bb69ed9f53d/after/3a65c4a145a573b2f991fb2a0982ba222e65cb30@github.com>

Reply all
Reply to author
Forward
0 new messages