Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lsp): check if the buffer is a directory before w! it #22289

Merged
merged 3 commits into from
Feb 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(lsp): make linter happy
  • Loading branch information
Trard committed Feb 16, 2023
commit f3606cd8b57617203c24699fbf33a63f01715157
4 changes: 3 additions & 1 deletion runtime/lua/vim/lsp/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,9 @@ function M.rename(old_fname, new_fname, opts)

-- The there may be pending changes in the buffer
if vim.fn.isdirectory(old_fname) == 0 then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this check whether 'buftype' is set on the old buffer? E.g. could the old buffer be a :terminal or other non-file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far as I know, LSP can rename only regular files and directories.

api.nvim_buf_call(oldbuf, function() vim.cmd('w!') end)
api.nvim_buf_call(oldbuf, function()
vim.cmd('w!')
end)
end

local ok, err = os.rename(old_fname, new_fname)
Expand Down