mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
lsp: Support text edit on inactive buffer (#11843)
Using `vim.lsp.buf.rename()` can result in receiving a TextEdit that affects a file for which there is no active or loaded buffer. In that case `api.nvim_buf_get_lines(...)` returned an empty result, leading to an error. Closes https://github.com/neovim/neovim/issues/11790
This commit is contained in:
parent
31614d3eb0
commit
174f7a2980
@ -88,6 +88,9 @@ function M.apply_text_edits(text_edits, bufnr)
|
||||
-- Reverse sort the orders so we can apply them without interfering with
|
||||
-- eachother. Also add i as a sort key to mimic a stable sort.
|
||||
table.sort(cleaned, edit_sort_key)
|
||||
if not api.nvim_buf_is_loaded(bufnr) then
|
||||
vim.fn.bufload(bufnr)
|
||||
end
|
||||
local lines = api.nvim_buf_get_lines(bufnr, start_line, finish_line + 1, false)
|
||||
local fix_eol = api.nvim_buf_get_option(bufnr, 'fixeol')
|
||||
local set_eol = fix_eol and api.nvim_buf_line_count(bufnr) <= finish_line + 1
|
||||
|
Loading…
Reference in New Issue
Block a user