mirror of
https://github.com/neovim/neovim.git
synced 2026-05-23 21:30:11 +00:00
fix(lsp): show_document can't position cursor past EOL in insert-mode #38566
Problem: vim.lsp.util.show_document insert mode is unable to set the cursor after the target character position if the target character is at end of line. Solution: Move cursor after the target character (in append position) in this case.
This commit is contained in:
@@ -1044,6 +1044,19 @@ function M.show_document(location, position_encoding, opts)
|
||||
-- Open folds under the cursor
|
||||
vim.cmd('normal! zv')
|
||||
end)
|
||||
|
||||
-- nvim_win_set_cursor clamps to last char at EOL. In insert mode the cursor
|
||||
-- should be past the last char (append position).
|
||||
if vim.api.nvim_get_mode().mode == 'i' then
|
||||
local line = api.nvim_buf_get_lines(bufnr, row, row + 1, false)[1] or ''
|
||||
if col >= #line then
|
||||
vim.api.nvim_feedkeys(
|
||||
vim.api.nvim_replace_termcodes('<End>', true, false, true),
|
||||
'n',
|
||||
false
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user