Skip to content

Commit

Permalink
fix(actions): CLI for setloclist and setqflist
Browse files Browse the repository at this point in the history
Fixes #880
  • Loading branch information
lewis6991 committed Sep 22, 2023
1 parent 0a3973d commit 3929cba
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lua/gitsigns/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ local function hunks_to_qflist(buf_or_filename, hunks, qflist)
end
end

---@param target 'all'|'attached'|integer
---@param target? 'all'|'attached'|integer
---@return table[]?
local function buildqflist(target)
target = target or current_buf()
Expand Down Expand Up @@ -1160,7 +1160,7 @@ end
--- Attributes: ~
--- {async}
---
--- @param target integer|string
--- @param target? integer|string
--- Specifies which files hunks are collected from.
--- Possible values.
--- • [integer]: The buffer with the matching buffer
Expand Down Expand Up @@ -1197,7 +1197,7 @@ M.setqflist = async.void(function(target, opts)
if config.trouble then
require('trouble').open('loclist')
else
vim.cmd([[lopen]])
vim.cmd.lopen()
end
end
else
Expand All @@ -1206,12 +1206,17 @@ M.setqflist = async.void(function(target, opts)
if config.trouble then
require('trouble').open('quickfix')
else
vim.cmd([[copen]])
vim.cmd.copen()
end
end
end
end)

C.setqflist = function(args, _)
local target = tonumber(args[2]) or args[2]
M.setqflist(target, args)
end

--- Populate the location list with hunks. Automatically opens the
--- location list window.
---
Expand All @@ -1220,16 +1225,21 @@ end)
--- Attributes: ~
--- {async}
---
--- @param nr integer Window number or the |window-ID|.
--- @param nr? integer Window number or the |window-ID|.
--- `0` for the current window (default).
--- @param target integer|string See |gitsigns.setqflist()|.
--- @param target? integer|string See |gitsigns.setqflist()|.
M.setloclist = function(nr, target)
M.setqflist(target, {
nr = nr,
use_location_list = true,
})
end

C.setloclist = function(args, _)
local target = tonumber(args[2]) or args[2]
M.setloclist(tonumber(args[1]), target)
end

--- Get all the available line specific actions for the current
--- buffer at the cursor position.
---
Expand Down

0 comments on commit 3929cba

Please sign in to comment.