Skip to content

Fixed and improved history window closing#39

Merged
moyiz merged 1 commit intomoyiz:masterfrom
jaynis:fix/close-history-window
Apr 13, 2026
Merged

Fixed and improved history window closing#39
moyiz merged 1 commit intomoyiz:masterfrom
jaynis:fix/close-history-window

Conversation

@jaynis
Copy link
Copy Markdown
Contributor

@jaynis jaynis commented Apr 9, 2026

Improved the history picker window closing by adding a small delay and fixed the issue where the window remained visible when selecting a repository in an non-telescope picker.

Changes:

  • Added explicit window closing for Snacks (picker:close()), Mini.pick (minipick.stop()), and vim.ui.select pickers
  • Added 50ms deferred call to select_entry() for all pickers (Snacks, Telescope, Mini.pick, vim.ui.select) to process the close commands and ensure a clean visual transition

Closes #38

@moyiz
Copy link
Copy Markdown
Owner

moyiz commented Apr 13, 2026

Thanks for taking the time to create a PR.

  • Why deferring with a small delay rather than vim.schedule?
  • Using it in select_entry itself is more sensible:
diff --git i/lua/git-dev/pickers/init.lua w/lua/git-dev/pickers/init.lua
index 38985bf..ac11b70 100644
--- i/lua/git-dev/pickers/init.lua
+++ w/lua/git-dev/pickers/init.lua
@@ -29,13 +29,15 @@ local P = {
       end,
       -- Action on selection
       select_entry = function(entry)
-        if entry then
-          require("git-dev").open(
-            entry.args.repo,
-            entry.args.ref,
-            entry.args.opts
-          )
-        end
+        vim.schedule(function()
+          if entry then
+            require("git-dev").open(
+              entry.args.repo,
+              entry.args.ref,
+              entry.args.opts
+            )
+          end
+        end)
       end,
       -- An array of an entry text parts
       label_parts = function(entry)
  • Please update the commit message to follow conventional commits format?

@jaynis jaynis force-pushed the fix/close-history-window branch from 590d865 to e74d93b Compare April 13, 2026 08:20
@jaynis
Copy link
Copy Markdown
Contributor Author

jaynis commented Apr 13, 2026

vim.schedule executes the function in the next event loop and I have made the experience that this is sometimes not enough when dealing with UI glitches. This is why using vim.def_fn with a 50ms delay is my go to approach in those situations. But I have quickly tested snacks with vim.schedule and in this case it seems to work as well.
Centralizing the logic for this is a good idea and I have adapted my PR accordingly.

Signed-off-by: jaynis <kranz.jannis@googlemail.com>
@moyiz moyiz force-pushed the fix/close-history-window branch from e74d93b to 8de07d5 Compare April 13, 2026 12:36
@moyiz moyiz merged commit 3b84d94 into moyiz:master Apr 13, 2026
2 checks passed
@moyiz
Copy link
Copy Markdown
Owner

moyiz commented Apr 13, 2026

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

History window fails to close after selection with snacks picker

2 participants