Skip to content

Commit

Permalink
Fix error in implicit save on empty buffer
Browse files Browse the repository at this point in the history
If you open up neovim and run `:set ft=java` there is no file name

Fixes #109
  • Loading branch information
mfussenegger committed Aug 6, 2021
1 parent a0c6b27 commit 2a9e673
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lua/jdtls/setup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ local function maybe_implicit_save()
if scheme ~= 'file' then
return
end
local stat = vim.loop.fs_stat(api.nvim_buf_get_name(bufnr))
local fname = api.nvim_buf_get_name(bufnr)
if fname == '' then
return
end
local stat = vim.loop.fs_stat(fname)
if not stat then
vim.fn.mkdir(vim.fn.expand('%:p:h'), 'p')
vim.cmd('w')
Expand Down

0 comments on commit 2a9e673

Please sign in to comment.