Skip to content

Commit

Permalink
fix: address comments, bugs, improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
fdschmidt93 committed Apr 24, 2022
1 parent 1aa25ec commit b93038d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
8 changes: 6 additions & 2 deletions lua/telescope/actions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -796,13 +796,15 @@ local send_selected_to_qf = function(prompt_bufnr, mode, target)
table.insert(qf_entries, entry_to_qf(entry))
end

local prompt = picker:_get_prompt()
actions.close(prompt_bufnr)

if target == "loclist" then
vim.fn.setloclist(picker.original_win_id, qf_entries, mode)
else
local qf_title = string.format([[%s (%s)]], picker.prompt_title, prompt)
vim.fn.setqflist(qf_entries, mode)
vim.fn.setqflist({}, "a", { title = picker.prompt_title })
vim.fn.setqflist({}, "a", { title = qf_title })
end
end

Expand All @@ -815,13 +817,15 @@ local send_all_to_qf = function(prompt_bufnr, mode, target)
table.insert(qf_entries, entry_to_qf(entry))
end

local prompt = picker:_get_prompt()
actions.close(prompt_bufnr)

if target == "loclist" then
vim.fn.setloclist(picker.original_win_id, qf_entries, mode)
else
vim.fn.setqflist(qf_entries, mode)
vim.fn.setqflist({}, "a", { title = picker.prompt_title })
local qf_title = string.format([[%s (%s)]], picker.prompt_title, prompt)
vim.fn.setqflist({}, "a", { title = qf_title })
end
end

Expand Down
19 changes: 9 additions & 10 deletions lua/telescope/builtin/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ internal.commands = function(opts)
end

internal.quickfix = function(opts)
opts = opts or {}
local qf_identifier = opts.id or vim.F.if_nil(opts.nr, "$")
local locations = vim.fn.getqflist({ [opts.id and "id" or "nr"] = qf_identifier, items = true }).items

Expand All @@ -370,14 +369,13 @@ internal.quickfix = function(opts)
end

internal.quickfixhistory = function(opts)
opts = opts or {}
local qflists = {}
for i = 1, 10 do -- (n)vim keeps at most 10 quickfix lists in full
local qflist = vim.fn.getqflist { nr = i, all = true }
if not qflist or (type(qflist) == "table" and vim.tbl_isempty(qflist.items)) then
break
-- qf weirdness: id = 0 gets id of quickfix list nr
local qflist = vim.fn.getqflist { nr = i, id = 0, title = true, items = true }
if not vim.tbl_isempty(qflist.items) then
table.insert(qflists, qflist)
end
table.insert(qflists, qflist)
end
local entry_maker = opts.make_entry
or function(entry)
Expand All @@ -387,6 +385,7 @@ internal.quickfixhistory = function(opts)
display = entry.title or "Untitled",
nr = entry.nr,
id = entry.id,
items = entry.items,
}
end
local qf_entry_maker = make_entry.gen_from_quickfix(opts)
Expand All @@ -397,6 +396,7 @@ internal.quickfixhistory = function(opts)
entry_maker = entry_maker,
},
previewer = previewers.new_buffer_previewer {
title = "Quickfix List Preview",
dyn_title = function(_, entry)
return entry.title
end,
Expand All @@ -406,13 +406,12 @@ internal.quickfixhistory = function(opts)
end,

define_preview = function(self, entry)
local qflist = vim.fn.getqflist({ nr = entry.nr, items = true }).items
local entries = vim.tbl_map(function(i)
return qf_entry_maker(i):display()
end, qflist)
if self.state.bufname then
return
end
local entries = vim.tbl_map(function(i)
return qf_entry_maker(i):display()
end, entry.items)
vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, entries)
end,
},
Expand Down

0 comments on commit b93038d

Please sign in to comment.