diff options
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 11 | ||||
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 3973e606f8..d2a5d9a08e 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -710,11 +710,12 @@ function M.rename(old_fname, new_fname, opts) end for _, b in ipairs(oldbufs) do - vim.fn.bufload(b) - -- The there may be pending changes in the buffer - api.nvim_buf_call(b, function() - vim.cmd('w!') - end) + -- There may be pending changes in the buffer + if api.nvim_buf_is_loaded(b) then + api.nvim_buf_call(b, function() + vim.cmd('update!') + end) + end end local newdir = assert(vim.fs.dirname(new_fname)) diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index b57fb268e1..0fdcd0dd1d 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -2611,7 +2611,7 @@ describe('LSP', function() eq(false, exec_lua('return vim.uv.fs_stat(...) ~= nil', old)) eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', new)) - eq('Old file\n', read_file(new)) + eq('Old file', read_file(new)) end) end) |