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.
This commit is contained in:
Michael Lingelbach
2022-01-14 08:02:44 -08:00
committed by GitHub
parent a88046fe2d
commit b72aae85fd

View File

@@ -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,