mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-13 17:40:25 +00:00
Merge pull request #246 from Khachig/no-leftover-empty-buffer
Remove empty `[No Name]` buffer when navigating to file.
This commit is contained in:
commit
fa3d8f725a
@ -190,6 +190,8 @@ function M.nav_file(id)
|
|||||||
local buf_id = get_or_create_buffer(filename)
|
local buf_id = get_or_create_buffer(filename)
|
||||||
local set_row = not vim.api.nvim_buf_is_loaded(buf_id)
|
local set_row = not vim.api.nvim_buf_is_loaded(buf_id)
|
||||||
|
|
||||||
|
local old_bufnr = vim.api.nvim_get_current_buf()
|
||||||
|
|
||||||
vim.api.nvim_set_current_buf(buf_id)
|
vim.api.nvim_set_current_buf(buf_id)
|
||||||
vim.api.nvim_buf_set_option(buf_id, "buflisted", true)
|
vim.api.nvim_buf_set_option(buf_id, "buflisted", true)
|
||||||
if set_row and mark.row and mark.col then
|
if set_row and mark.row and mark.col then
|
||||||
@ -202,6 +204,14 @@ function M.nav_file(id)
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local old_bufinfo = vim.fn.getbufinfo(old_bufnr)[1]
|
||||||
|
local no_name = old_bufinfo.name == ""
|
||||||
|
local one_line = old_bufinfo.linecount == 1
|
||||||
|
local unchanged = old_bufinfo.changed == 0
|
||||||
|
if no_name and one_line and unchanged then
|
||||||
|
vim.api.nvim_buf_delete(old_bufnr, {})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.location_window(options)
|
function M.location_window(options)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user