Skip to content

Commit

Permalink
refactor: Jumplist picker uses quickfix entry maker. Delete jumplist …
Browse files Browse the repository at this point in the history
…entry maker. (#973)
  • Loading branch information
caojoshua authored Jul 11, 2021
1 parent 7cdaaaa commit dc0dca2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 50 deletions.
9 changes: 6 additions & 3 deletions lua/telescope/builtin/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -951,15 +951,18 @@ internal.jumplist = function(opts)
-- reverse the list
local sorted_jumplist = {}
for i = #jumplist, 1, -1 do
jumplist[i].text = ''
table.insert(sorted_jumplist, jumplist[i])
if vim.api.nvim_buf_is_valid(jumplist[i].bufnr) then
jumplist[i].text = vim.api.nvim_buf_get_lines(jumplist[i].bufnr, jumplist[i].lnum, jumplist[i].lnum+1,
false)[1] or ''
table.insert(sorted_jumplist, jumplist[i])
end
end

pickers.new(opts, {
prompt_title = 'Jumplist',
finder = finders.new_table {
results = sorted_jumplist,
entry_maker = make_entry.gen_from_jumplist(opts),
entry_maker = make_entry.gen_from_quickfix(opts),
},
previewer = conf.qflist_previewer(opts),
sorter = conf.generic_sorter(opts),
Expand Down
47 changes: 0 additions & 47 deletions lua/telescope/make_entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1111,52 +1111,5 @@ function make_entry.gen_from_git_status(opts)
end
end

function make_entry.gen_from_jumplist(opts)
opts = opts or {}

local displayer = entry_display.create {
separator = "",
items = {
{ width = 10 },
{ remaining = true },
}
}

local make_display = function(entry)
local filename = utils.transform_path(opts, entry.filename)

local line_info = {table.concat({entry.lnum, entry.col}, ":"), "TelescopeResultsLineNr"}

return displayer {
line_info,
filename,
}
end

return function(entry)
if not vim.api.nvim_buf_is_valid(entry.bufnr) then
return
end

local filename = entry.filename or vim.api.nvim_buf_get_name(entry.bufnr)

return {
valid = true,

value = entry,
ordinal = (
not opts.ignore_filename and filename
or ''
) .. ' ' .. entry.text,
display = make_display,

bufnr = entry.bufnr,
filename = filename,
lnum = entry.lnum,
col = entry.col,
}
end
end


return make_entry

0 comments on commit dc0dca2

Please sign in to comment.