Add tests

This commit is contained in:
hrsh7th
2021-11-15 12:44:41 +09:00
parent 753f5b7c92
commit c194a3dbba
3 changed files with 80 additions and 48 deletions

View File

@@ -389,22 +389,21 @@ core.confirm = function(self, e, option, callback)
completion_item.textEdit.newText = ''
end
vim.fn['cmp#apply_text_edits'](ctx.bufnr, { completion_item.textEdit })
local texts = vim.split(completion_item.textEdit.newText, '\n')
local position = completion_item.textEdit.range.start
position.line = position.line + (#texts - 1)
if #texts == 1 then
position.character = position.character + vim.str_utfindex(texts[1])
else
position.character = vim.str_utfindex(texts[#texts])
end
local pos = types.lsp.Position.to_vim(0, position)
vim.api.nvim_win_set_cursor(0, { pos.row, pos.col - 1 })
if is_snippet then
config.get().snippet.expand({
body = new_text,
insert_text_mode = completion_item.insertTextMode,
})
else
local texts = vim.split(completion_item.textEdit.newText, '\n')
local position = completion_item.textEdit.range.start
position.line = position.line + (#texts - 1)
if #texts == 1 then
position.character = position.character + vim.str_utfindex(texts[1])
else
position.character = vim.str_utfindex(texts[#texts])
end
local pos = types.lsp.Position.to_vim(0, position)
vim.api.nvim_win_set_cursor(0, { pos.row, pos.col - 1 })
end
else
local keys = {}