Skip to content

Commit

Permalink
fix: use context.get_line() when getting preview undo text edit
Browse files Browse the repository at this point in the history
Closes #702
  • Loading branch information
Saghen committed Dec 21, 2024
1 parent 81d5d90 commit 0f92fb8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lua/blink/cmp/completion/list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ function list.undo_preview()
if list.preview_undo == nil then return end

require('blink.cmp.lib.text_edits').apply({ list.preview_undo.text_edit })
if list.preview_undo.cursor then vim.api.nvim_win_set_cursor(0, list.preview_undo.cursor) end
if list.preview_undo.cursor then
require('blink.cmp.completion.trigger.context').set_cursor(list.preview_undo.cursor)
end
list.preview_undo = nil
end

Expand Down
3 changes: 1 addition & 2 deletions lua/blink/cmp/lib/text_edits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ end
--- @param text_edit lsp.TextEdit
--- @return string
function text_edits.get_text_to_replace(text_edit)
local bufnr = vim.api.nvim_get_current_buf()
local lines = {}
for line = text_edit.range.start.line, text_edit.range['end'].line do
local line_text = vim.api.nvim_buf_get_lines(bufnr, line, line + 1, false)[1]
local line_text = context.get_line()
local is_start_line = line == text_edit.range.start.line
local is_end_line = line == text_edit.range['end'].line

Expand Down

0 comments on commit 0f92fb8

Please sign in to comment.