Skip to content

Commit

Permalink
fix: scroll cmdline to make sure cursor is always visible. Fixes #196
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Nov 7, 2022
1 parent 9dc2508 commit e023c5f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lua/noice/ui/cmdline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ function M.on_render(_, buf, line, byte)
-- FIXME: check with cmp
-- FIXME: state.pos?
local cmdline_start = byte - (M.last():length() - M.last().offset)

local cursor = byte - M.last():length() + M.last().state.pos
vim.api.nvim_win_set_cursor(win, { 1, cursor })
vim.api.nvim_win_call(win, function()
vim.cmd([[silent! normal! ze]])
end)

local pos = vim.fn.screenpos(win, line, cmdline_start)
M.position = {
buf = buf,
Expand Down

0 comments on commit e023c5f

Please sign in to comment.