Skip to content

Commit

Permalink
use diff
Browse files Browse the repository at this point in the history
  • Loading branch information
xzbdmw committed Jan 8, 2025
1 parent f9d4b20 commit 117eee0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lua/blink/cmp/completion/list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,13 @@ end
---------- Preview ----------

function list.restore_content()
-- compute the diff between the current cursor column and the cursor column when the request was sent.
local diff = vim.api.nvim_win_get_cursor(0)[2] - list.context.bounds.start_col
if diff <= 0 then return end
local row = list.context.cursor[1] - 1
vim.api.nvim_buf_set_text(0, row, 0, row, -1, { list.context.get_line() })

-- delete those chars added by previous auto-insert
vim.api.nvim_buf_set_text(0, row, list.context.bounds.start_col, row, vim.api.nvim_win_get_cursor(0)[2], { '' })
end

function list.apply_preview(item)
Expand Down

0 comments on commit 117eee0

Please sign in to comment.