Merge pull request #14603 from folke/format_on_save

fix(lsp): allow apply_text_edits to append text (insert at last line)
This commit is contained in:
Michael Lingelbach 2021-05-22 09:13:06 -07:00 committed by GitHub
commit 9c7ad33006
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,7 +73,7 @@ function M.set_lines(lines, A, B, new_lines)
-- way the LSP describes the range including the last newline is by -- way the LSP describes the range including the last newline is by
-- specifying a line number after what we would call the last line. -- specifying a line number after what we would call the last line.
local i_n = math.min(B[1] + 1, #lines) local i_n = math.min(B[1] + 1, #lines)
if not (i_0 >= 1 and i_0 <= #lines and i_n >= 1 and i_n <= #lines) then if not (i_0 >= 1 and i_0 <= #lines + 1 and i_n >= 1 and i_n <= #lines) then
error("Invalid range: "..vim.inspect{A = A; B = B; #lines, new_lines}) error("Invalid range: "..vim.inspect{A = A; B = B; #lines, new_lines})
end end
local prefix = "" local prefix = ""