Skip to content

Commit

Permalink
fix(input): skip cursor position patch for hidden input
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter authored Dec 28, 2023
1 parent cbfb97c commit 80445d0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lua/nui/input/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ function Input:unmount()
return
end

local target_cursor = vim.api.nvim_win_get_cursor(self._.position.win)

local position_win = self._.position.win
local target_cursor = vim.api.nvim_win_is_valid(position_win) and vim.api.nvim_win_get_cursor(position_win) or nil
local prompt_mode = vim.fn.mode()

Input.super.unmount(self)
Expand All @@ -151,7 +151,7 @@ function Input:unmount()
vim.api.nvim_command("stopinsert")
end

if not self._.disable_cursor_position_patch then
if not self._.disable_cursor_position_patch and target_cursor ~= nil then
patch_cursor_position(target_cursor, pending_submit_value and prompt_mode == "n")
end

Expand Down

0 comments on commit 80445d0

Please sign in to comment.