aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2022-01-14 08:02:44 -0800
committerGitHub <noreply@github.com>2022-01-14 08:02:44 -0800
commitb72aae85fd980b55a695543c1c34e8f0bf584cc4 (patch)
tree49877df75de84a962906a3781d615d7e835dc964 /runtime/lua/vim/lsp/util.lua
parenta88046fe2d0710d1d1132ea544e9dbbbac1af7de (diff)
downloadrneovim-b72aae85fd980b55a695543c1c34e8f0bf584cc4.tar.gz
rneovim-b72aae85fd980b55a695543c1c34e8f0bf584cc4.tar.bz2
rneovim-b72aae85fd980b55a695543c1c34e8f0bf584cc4.zip
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.
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua3
1 files changed, 3 insertions, 0 deletions
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,