From bccedaf88b1ba4e1e0c5abc1e902cba8638df4bc Mon Sep 17 00:00:00 2001 From: James Trew <66286082+jamestrew@users.noreply.github.com> Date: Mon, 25 Dec 2023 14:17:41 -0500 Subject: [PATCH] fix(git_status): keep picker open with no matches (#2825) Previously, `git_status` with a prompt that has zero matches closes the picker. Only automatically close the picker if working tree is completely clean. If working tree is not clean, and a prompt is given but no matches are found, keep the picker open. This behavior is consistent with other pickers where lack of matches doesn't result in the picker closing. closes #2815 --- lua/telescope/builtin/__git.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/telescope/builtin/__git.lua b/lua/telescope/builtin/__git.lua index 8c38383..d7964f1 100644 --- a/lua/telescope/builtin/__git.lua +++ b/lua/telescope/builtin/__git.lua @@ -390,7 +390,14 @@ git.status = function(opts) on_complete = { function(self) local lines = self.manager:num_results() - if lines == 0 then + + -- HACK: unable to `self._get_prompt()` directly + local cursor_line = vim.api.nvim_win_get_cursor(self.prompt_win)[1] - 1 + local prompt = vim.api + .nvim_buf_get_lines(self.prompt_bufnr, cursor_line, cursor_line + 1, false)[1] + :sub(#self.prompt_prefix + 1) + + if lines == 0 and prompt == "" then utils.notify("builtin.git_status", { msg = "No changes found", level = "ERROR",