fix: git stash entry formatting (#1452)
This commit is contained in:
committed by
GitHub
parent
a20f01353b
commit
6b1579741a
@@ -72,7 +72,8 @@ git.commits = function(opts)
|
||||
end
|
||||
|
||||
git.stash = function(opts)
|
||||
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_stash())
|
||||
opts.show_branch = vim.F.if_nil(opts.show_branch, true)
|
||||
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_stash(opts))
|
||||
|
||||
pickers.new(opts, {
|
||||
prompt_title = "Git Stash",
|
||||
|
||||
@@ -204,6 +204,7 @@ builtin.git_status = require_on_exported_call("telescope.builtin.git").status
|
||||
---@param opts table: options to pass to the picker
|
||||
---@field cwd string: specify the path of the repo
|
||||
---@field use_git_root boolean: if we should use git root as cwd or the cwd (important for submodule) (default: true)
|
||||
---@field show_branch boolean: if we should display the branch name for git stash entries (default: true)
|
||||
builtin.git_stash = require_on_exported_call("telescope.builtin.git").stash
|
||||
|
||||
--
|
||||
|
||||
@@ -249,16 +249,40 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
function make_entry.gen_from_git_stash()
|
||||
function make_entry.gen_from_git_stash(opts)
|
||||
local displayer = entry_display.create {
|
||||
separator = " ",
|
||||
items = {
|
||||
{ width = 10 },
|
||||
opts.show_branch and { width = 15 } or "",
|
||||
{ remaining = true },
|
||||
},
|
||||
}
|
||||
|
||||
local make_display = function(entry)
|
||||
return displayer {
|
||||
{ entry.value, "TelescopeResultsLineNr" },
|
||||
opts.show_branch and { entry.branch_name, "TelescopeResultsIdentifier" } or "",
|
||||
entry.commit_info,
|
||||
}
|
||||
end
|
||||
|
||||
return function(entry)
|
||||
if entry == "" then
|
||||
return nil
|
||||
end
|
||||
local splitted = vim.split(entry, ":")
|
||||
|
||||
local splitted = utils.max_split(entry, ": ", 2)
|
||||
local stash_idx = splitted[1]
|
||||
local _, branch_name = string.match(splitted[2], "^([WIP on|On]+) (.+)")
|
||||
local commit_info = splitted[3]
|
||||
|
||||
return {
|
||||
value = splitted[1],
|
||||
ordinal = splitted[3],
|
||||
display = splitted[3],
|
||||
value = stash_idx,
|
||||
ordinal = commit_info,
|
||||
branch_name = branch_name,
|
||||
commit_info = commit_info,
|
||||
display = make_display,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user