Closed hieulw closed 5 months ago
Nvim Version
NVIM v0.10.0-dev-3057+g9e2f378b6d Build type: RelWithDebInfo LuaJIT 2.1.1713773202
Code to reproduce
local Input = require("nui.input") local event = require("nui.utils.autocmd").event local input = Input({ relative = "cursor", position = { row = 0, col = 0, }, size = { width = 20, }, border = { style = "rounded", text = { top_align = "center", }, }, }, { default_value = "Hello", }) -- mount/open the component input:mount() -- unmount component when cursor leaves buffer input:on(event.BufLeave, function() input:unmount() end)
patch_cursor_position is used when exiting insert mode with <CR> places cursor one character backward. When relative is cursor, the patch_cursor_position function doesn't run due to target_cursor and cursor not relate. https://github.com/MunifTanjim/nui.nvim/blob/cbd2668414331c10039278f558630ed19b93e69b/lua/nui/input/init.lua#L12-L22 In this context, the target_cursor is actually the cursor position of the input prompt not the previous cursor position before open prompt. This commit https://github.com/MunifTanjim/nui.nvim/commit/3dc46d725f7b94bee5117c0a699b57b1902b5d65 I don't know what problem it fixes but revert it works like expected.
patch_cursor_position
<CR>
cursor
target_cursor
https://github.com/MunifTanjim/nui.nvim/assets/13571960/1530b96b-11a6-47ae-a00a-135a7ffd8a62
Should be fixed now.
Nvim Version
Code to reproduce
patch_cursor_position
is used when exiting insert mode with<CR>
places cursor one character backward. When relative iscursor
, thepatch_cursor_position
function doesn't run due totarget_cursor
andcursor
not relate. https://github.com/MunifTanjim/nui.nvim/blob/cbd2668414331c10039278f558630ed19b93e69b/lua/nui/input/init.lua#L12-L22 In this context, thetarget_cursor
is actually the cursor position of the input prompt not the previous cursor position before open prompt. This commit https://github.com/MunifTanjim/nui.nvim/commit/3dc46d725f7b94bee5117c0a699b57b1902b5d65 I don't know what problem it fixes but revert it works like expected.https://github.com/MunifTanjim/nui.nvim/assets/13571960/1530b96b-11a6-47ae-a00a-135a7ffd8a62