From b72aae85fd980b55a695543c1c34e8f0bf584cc4 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Fri, 14 Jan 2022 08:02:44 -0800 Subject: fix(lsp): always split text edits on \r, \r\n, and \n (#17087) Closes: https://github.com/neovim/neovim/issues/17053 Servers can return a mix of line endings per the language server protocol. See: https://microsoft.github.io/language-server-protocol/specification.html#textDocuments All should be equally treated as line endings. --- runtime/lua/vim/lsp/util.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 4cbd8c9554..8be1683d86 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -422,6 +422,9 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding) local is_cursor_fixed = false local has_eol_text_edit = false for _, text_edit in ipairs(text_edits) do + -- Normalize line ending + text_edit.newText, _ = string.gsub(text_edit.newText, '\r\n?', '\n') + -- Convert from LSP style ranges to Neovim style ranges. local e = { start_row = text_edit.range.start.line, -- cgit