Skip to content

Commit

Permalink
fix(util): auto_jump when trouble is open. Fixes #144
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Apr 17, 2023
1 parent f0477b0 commit e4f1623
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lua/trouble/init.lua
Expand Up @@ -61,6 +61,7 @@ function Trouble.open(...)
config.options.mode = opts.mode
end
opts.focus = true
opts.on_open = true

if Trouble.is_open() then
Trouble.refresh(opts)
Expand Down
7 changes: 7 additions & 0 deletions lua/trouble/renderer.lua
Expand Up @@ -35,6 +35,13 @@ function renderer.render(view, opts)
opts = opts or {}
local buf = vim.api.nvim_win_get_buf(view.parent)
providers.get(view.parent, buf, function(items)
local auto_jump = vim.tbl_contains(config.options.auto_jump, opts.mode)
if opts.on_open and #items == 1 and auto_jump and not opts.auto then
view:close()
util.jump_to_item(opts.win, opts.precmd, items[1])
return
end

local grouped = providers.group(items)
local count = util.count(grouped)

Expand Down

0 comments on commit e4f1623

Please sign in to comment.