From 97087a51ff93b52959cdef00cb77245ab68e655b Mon Sep 17 00:00:00 2001 From: Daniel Vieites Date: Sun, 21 Dec 2025 19:34:08 +0100 Subject: [PATCH 1/5] fix: statusline showing --- lua/command/history.lua | 4 ++++ lua/command/prompt.lua | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lua/command/history.lua b/lua/command/history.lua index 3819594..0d8bcec 100644 --- a/lua/command/history.lua +++ b/lua/command/history.lua @@ -242,6 +242,10 @@ function M.search(callback) winopts = { height = 0.35, width = 0.5, + -- Use a minimal style with proper border + title = 'Command History', + title_pos = 'center', + border = 'rounded', }, actions = { default = function(selected) diff --git a/lua/command/prompt.lua b/lua/command/prompt.lua index 11e46b3..2142ea6 100644 --- a/lua/command/prompt.lua +++ b/lua/command/prompt.lua @@ -61,8 +61,16 @@ function M.create(opts) return nil end - -- Set window-local options for text handling + -- Set window-local options vim.api.nvim_set_option_value('wrap', false, { win = win }) + + -- Explicitly disable statusline to prevent it from being shown after fzf + vim.api.nvim_win_set_option(win, 'statusline', '') + + -- Ensure minimal UI is applied + local win_config = vim.api.nvim_win_get_config(win) + win_config.style = 'minimal' + vim.api.nvim_win_set_config(win, win_config) -- 6. Register in state state.add_window({ @@ -219,6 +227,32 @@ function M.search_history() return end + -- Function to reset the window appearance after fzf closes + local function reset_window_appearance() + if vim.api.nvim_win_is_valid(window.win) then + -- Reset window options that might have been changed by fzf + vim.api.nvim_win_set_option(window.win, 'statusline', '') + + -- Reapply the style=minimal setting + local win_config = vim.api.nvim_win_get_config(window.win) + win_config.style = 'minimal' + vim.api.nvim_win_set_config(window.win, win_config) + end + end + + -- Set up a one-time autocmd to reset window after returning to prompt + local autocmd_id = vim.api.nvim_create_autocmd('BufWinEnter', { + callback = function(args) + if args.buf == window.buf then + -- Reset window appearance + vim.defer_fn(reset_window_appearance, 1) + -- Remove this autocmd after it fires once + vim.api.nvim_del_autocmd(autocmd_id) + end + end, + once = true, + }) + history.search(function(selected_cmd) if selected_cmd and vim.api.nvim_buf_is_valid(window.buf) then utils.set_cmd_prompt(window.buf, window.win, selected_cmd) From 5e5241625f35bcd9f07f161f7345fded357d0417 Mon Sep 17 00:00:00 2001 From: Daniel Vieites Date: Sun, 21 Dec 2025 19:39:42 +0100 Subject: [PATCH 2/5] fix: try a differente approach --- lua/command/prompt.lua | 57 +++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/lua/command/prompt.lua b/lua/command/prompt.lua index 2142ea6..a272f39 100644 --- a/lua/command/prompt.lua +++ b/lua/command/prompt.lua @@ -227,38 +227,39 @@ function M.search_history() return end - -- Function to reset the window appearance after fzf closes - local function reset_window_appearance() - if vim.api.nvim_win_is_valid(window.win) then - -- Reset window options that might have been changed by fzf - vim.api.nvim_win_set_option(window.win, 'statusline', '') - - -- Reapply the style=minimal setting - local win_config = vim.api.nvim_win_get_config(window.win) - win_config.style = 'minimal' - vim.api.nvim_win_set_config(window.win, win_config) - end + -- Save current content and options + local content = "" + local win_opts = {} + + if vim.api.nvim_buf_is_valid(window.buf) then + local lines = vim.api.nvim_buf_get_lines(window.buf, 0, -1, false) + content = lines[1] or "" + win_opts = window.opts or {} end - - -- Set up a one-time autocmd to reset window after returning to prompt - local autocmd_id = vim.api.nvim_create_autocmd('BufWinEnter', { - callback = function(args) - if args.buf == window.buf then - -- Reset window appearance - vim.defer_fn(reset_window_appearance, 1) - -- Remove this autocmd after it fires once - vim.api.nvim_del_autocmd(autocmd_id) - end - end, - once = true, - }) + + -- Close the window to avoid statusline leaking + if vim.api.nvim_win_is_valid(window.win) then + vim.api.nvim_win_close(window.win, true) + end + + -- Remove from state + state.remove_window_by_name(WINDOW_NAME) history.search(function(selected_cmd) - if selected_cmd and vim.api.nvim_buf_is_valid(window.buf) then - utils.set_cmd_prompt(window.buf, window.win, selected_cmd) - + -- Recreate the prompt window + local new_win = M.create(win_opts) + + if new_win then + -- Set the prompt content + if selected_cmd then + utils.set_cmd_prompt(new_win.buf, new_win.win, selected_cmd) + else + utils.set_cmd_prompt(new_win.buf, new_win.win, content) + end + + -- Attach ghost text if enabled if config.values.ui.prompt.ghost_text then - ghost_text.update(window.buf) + ghost_text.update(new_win.buf) end end end) From 34b23173ec7452ec1ff759d497532e2c4b16a2b6 Mon Sep 17 00:00:00 2001 From: Daniel Vieites Date: Sun, 21 Dec 2025 19:41:41 +0100 Subject: [PATCH 3/5] fix: nil error --- lua/command/prompt.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lua/command/prompt.lua b/lua/command/prompt.lua index a272f39..b148b55 100644 --- a/lua/command/prompt.lua +++ b/lua/command/prompt.lua @@ -63,10 +63,10 @@ function M.create(opts) -- Set window-local options vim.api.nvim_set_option_value('wrap', false, { win = win }) - + -- Explicitly disable statusline to prevent it from being shown after fzf vim.api.nvim_win_set_option(win, 'statusline', '') - + -- Ensure minimal UI is applied local win_config = vim.api.nvim_win_get_config(win) win_config.style = 'minimal' @@ -228,27 +228,27 @@ function M.search_history() end -- Save current content and options - local content = "" + local content = '' local win_opts = {} - + if vim.api.nvim_buf_is_valid(window.buf) then local lines = vim.api.nvim_buf_get_lines(window.buf, 0, -1, false) - content = lines[1] or "" + content = lines[1] or '' win_opts = window.opts or {} end - + -- Close the window to avoid statusline leaking if vim.api.nvim_win_is_valid(window.win) then vim.api.nvim_win_close(window.win, true) end - + -- Remove from state - state.remove_window_by_name(WINDOW_NAME) + state.remove_window(WINDOW_NAME) history.search(function(selected_cmd) -- Recreate the prompt window local new_win = M.create(win_opts) - + if new_win then -- Set the prompt content if selected_cmd then @@ -256,7 +256,7 @@ function M.search_history() else utils.set_cmd_prompt(new_win.buf, new_win.win, content) end - + -- Attach ghost text if enabled if config.values.ui.prompt.ghost_text then ghost_text.update(new_win.buf) From 14c3a03646cba15529fe0bbe4ecdc7690a6632d3 Mon Sep 17 00:00:00 2001 From: Daniel Vieites Date: Sun, 21 Dec 2025 19:46:59 +0100 Subject: [PATCH 4/5] fix: esc on picker --- lua/command/history.lua | 12 +++++++----- lua/command/prompt.lua | 14 +++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lua/command/history.lua b/lua/command/history.lua index 0d8bcec..318e0e4 100644 --- a/lua/command/history.lua +++ b/lua/command/history.lua @@ -242,10 +242,6 @@ function M.search(callback) winopts = { height = 0.35, width = 0.5, - -- Use a minimal style with proper border - title = 'Command History', - title_pos = 'center', - border = 'rounded', }, actions = { default = function(selected) @@ -253,7 +249,13 @@ function M.search(callback) callback(selected[1]) end end, - }, + -- Add a quit action that calls the callback with nil + -- This ensures the prompt is recreated on escape + ["quit"] = function() + callback(nil) + return true -- Return true to close fzf + end + } } -- Position below prompt if it exists, matching its dimensions diff --git a/lua/command/prompt.lua b/lua/command/prompt.lua index b148b55..b4b651a 100644 --- a/lua/command/prompt.lua +++ b/lua/command/prompt.lua @@ -245,10 +245,11 @@ function M.search_history() -- Remove from state state.remove_window(WINDOW_NAME) - history.search(function(selected_cmd) - -- Recreate the prompt window + -- Simple callback that recreates the window and restores content + local function on_history_selection(selected_cmd) + -- Always recreate the window local new_win = M.create(win_opts) - + if new_win then -- Set the prompt content if selected_cmd then @@ -256,13 +257,16 @@ function M.search_history() else utils.set_cmd_prompt(new_win.buf, new_win.win, content) end - + -- Attach ghost text if enabled if config.values.ui.prompt.ghost_text then ghost_text.update(new_win.buf) end end - end) + end + + -- Call history search with the callback + history.search(on_history_selection) end ---Accepts the ghost text suggestion From 0c6db3b2b791e59d4336d74b81048d9a0b8d3f17 Mon Sep 17 00:00:00 2001 From: Daniel Vieites Date: Sun, 21 Dec 2025 19:47:28 +0100 Subject: [PATCH 5/5] style: formatting --- lua/command/prompt.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/command/prompt.lua b/lua/command/prompt.lua index b4b651a..e6a01c7 100644 --- a/lua/command/prompt.lua +++ b/lua/command/prompt.lua @@ -249,7 +249,7 @@ function M.search_history() local function on_history_selection(selected_cmd) -- Always recreate the window local new_win = M.create(win_opts) - + if new_win then -- Set the prompt content if selected_cmd then @@ -257,14 +257,14 @@ function M.search_history() else utils.set_cmd_prompt(new_win.buf, new_win.win, content) end - + -- Attach ghost text if enabled if config.values.ui.prompt.ghost_text then ghost_text.update(new_win.buf) end end end - + -- Call history search with the callback history.search(on_history_selection) end