From 82c3b544291380bbcb937e837ed12d69392d396d Mon Sep 17 00:00:00 2001 From: Studio 90 Date: Sun, 19 May 2024 21:27:32 +0200 Subject: [PATCH 1/2] fix(quickfix): auto_close_when_success false is ignored When the runner/executor is set to `quickfix` and in the options `auto_close_when_success` is set to false, the quickfix window does not remain open. This PR adds the missing check when success code = 0, auto close = false. The issue is referenced also in the first bullet of https://github.com/Civitasv/cmake-tools.nvim/issues/201#issuecomment-2022290445 --- lua/cmake-tools/quickfix.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/cmake-tools/quickfix.lua b/lua/cmake-tools/quickfix.lua index 946a0bd8..7159a0ae 100644 --- a/lua/cmake-tools/quickfix.lua +++ b/lua/cmake-tools/quickfix.lua @@ -73,6 +73,10 @@ function _quickfix.run(cmd, env_script, env, args, cwd, opts, on_exit, on_output _quickfix.close(opts) end, 100) end + if code == 0 and not opts.auto_close_when_success then + _quickfix.show(opts) + _quickfix.scroll_to_bottom() + end if on_exit ~= nil then on_exit(code) end From cdabc3bd66b7be851e74e200b4c48f8a48a9d564 Mon Sep 17 00:00:00 2001 From: Studio 90 Date: Mon, 20 May 2024 13:10:46 +0200 Subject: [PATCH 2/2] fix(quickfix): remove vim_defer_fn() on close Remove `vim.defer_fn()` when closing the executor/runner to avoid synchronization issues. --- lua/cmake-tools/quickfix.lua | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lua/cmake-tools/quickfix.lua b/lua/cmake-tools/quickfix.lua index 7159a0ae..7297378a 100644 --- a/lua/cmake-tools/quickfix.lua +++ b/lua/cmake-tools/quickfix.lua @@ -69,13 +69,7 @@ function _quickfix.run(cmd, env_script, env, args, cwd, opts, on_exit, on_output _quickfix.scroll_to_bottom() end if code == 0 and opts.auto_close_when_success then - vim.defer_fn(function() - _quickfix.close(opts) - end, 100) - end - if code == 0 and not opts.auto_close_when_success then - _quickfix.show(opts) - _quickfix.scroll_to_bottom() + _quickfix.close(opts) end if on_exit ~= nil then on_exit(code)