Skip to content

Commit

Permalink
fix(util): properly load a buffer when jumping to it
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Feb 16, 2023
1 parent 3ffe891 commit bf0eeea
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lua/trouble/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ function M.jump_to_item(win, precmd, item)
if precmd then
vim.cmd(precmd)
end
if vim.api.nvim_buf_get_option(item.bufnr, "buflisted") == false then
vim.cmd("edit #" .. item.bufnr)
else
vim.cmd("buffer " .. item.bufnr)
if not vim.bo[item.bufnr].buflisted then
vim.bo[item.bufnr].buflisted = true
end
if not vim.api.nvim_buf_is_loaded(item.bufnr) then
vim.fn.bufload(item.bufnr)
end
vim.api.nvim_set_current_buf(item.bufnr)
vim.api.nvim_win_set_cursor(win or 0, { item.start.line + 1, item.start.character })
end

Expand Down

0 comments on commit bf0eeea

Please sign in to comment.