From f2f382e2baf94fb5491883bfe9fc4e7a160781ff Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 4 Jan 2023 23:45:03 +0100 Subject: fix completions using textEdit Fix the off-by-one manual range conversion by using the already available helper function. --- init.lua | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/init.lua b/init.lua index dd55949..3cd4626 100644 --- a/init.lua +++ b/init.lua @@ -333,16 +333,7 @@ end local function vis_apply_textEdit(win, file, textEdit) assert(win.file == file) - local start_pos = lsp_pos_to_vis_sel(textEdit.range.start) - local end_pos = lsp_pos_to_vis_sel(textEdit.range['end']) - - -- convert the LSP range into a vis range - -- this destroys the current selection but we change it after the edit anyway - win.selection.anchored = false - win.selection:to(start_pos.line, start_pos.col) - win.selection.anchored = true - win.selection:to(end_pos.line, end_pos.col - 1) - local range = win.selection.range + local range = lsp_range_to_vis_range(win, textEdit.range) file:delete(range) file:insert(range.start, textEdit.newText) -- cgit v1.2.3