Skip to content

Commit 928e6d0

Browse files
authored
feat(config): add close counterparts to jump split actions (#584)
## Description Adds `jump_split_close` and `jump_vsplit_close` actions.
1 parent 9297d81 commit 928e6d0

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,21 @@ require("trouble").jump_only(opts)
555555
---@return trouble.View
556556
require("trouble").jump_split(opts)
557557

558+
-- Open the item in a split and close the trouble window
559+
---@param opts? trouble.Mode | { new? : boolean } | string
560+
---@return trouble.View
561+
require("trouble").jump_split_close(opts)
562+
558563
-- Open the item in a vsplit
559564
---@param opts? trouble.Mode | { new? : boolean } | string
560565
---@return trouble.View
561566
require("trouble").jump_vsplit(opts)
562567

568+
-- Open the item in a vsplit and close the trouble window
569+
---@param opts? trouble.Mode | { new? : boolean } | string
570+
---@return trouble.View
571+
require("trouble").jump_vsplit_close(opts)
572+
563573
-- Go to the last item
564574
---@param opts? trouble.Mode | { new? : boolean } | string
565575
---@return trouble.View

lua/trouble/config/actions.lua

+14
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,26 @@ local M = {
114114
self:jump(ctx.item, { split = true })
115115
end
116116
end,
117+
-- Open the item in a split and close the trouble window
118+
jump_split_close = function(self, ctx)
119+
if ctx.item then
120+
self:jump(ctx.item, { split = true })
121+
self:close()
122+
end
123+
end,
117124
-- Open the item in a vsplit
118125
jump_vsplit = function(self, ctx)
119126
if ctx.item then
120127
self:jump(ctx.item, { vsplit = true })
121128
end
122129
end,
130+
-- Open the item in a vsplit and close the trouble window
131+
jump_vsplit_close = function(self, ctx)
132+
if ctx.item then
133+
self:jump(ctx.item, { vsplit = true })
134+
self:close()
135+
end
136+
end,
123137
-- Dump the item to the console
124138
inspect = function(_, ctx)
125139
vim.print(ctx.item or (ctx.node and ctx.node.item))

0 commit comments

Comments
 (0)