fix: git stash entry formatting (#1452)
This commit is contained in:
committed by
GitHub
parent
a20f01353b
commit
6b1579741a
@@ -989,6 +989,8 @@ builtin.git_stash({opts}) *builtin.git_stash()*
|
|||||||
{cwd} (string) specify the path of the repo
|
{cwd} (string) specify the path of the repo
|
||||||
{use_git_root} (boolean) if we should use git root as cwd or the cwd
|
{use_git_root} (boolean) if we should use git root as cwd or the cwd
|
||||||
(important for submodule) (default: true)
|
(important for submodule) (default: true)
|
||||||
|
{show_branch} (boolean) if we should display the branch name for git
|
||||||
|
stash entries (default: true)
|
||||||
|
|
||||||
|
|
||||||
builtin.builtin({opts}) *builtin.builtin()*
|
builtin.builtin({opts}) *builtin.builtin()*
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ git.commits = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
git.stash = function(opts)
|
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, {
|
pickers.new(opts, {
|
||||||
prompt_title = "Git Stash",
|
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
|
---@param opts table: options to pass to the picker
|
||||||
---@field cwd string: specify the path of the repo
|
---@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 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
|
builtin.git_stash = require_on_exported_call("telescope.builtin.git").stash
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -249,16 +249,40 @@ do
|
|||||||
end
|
end
|
||||||
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)
|
return function(entry)
|
||||||
if entry == "" then
|
if entry == "" then
|
||||||
return nil
|
return nil
|
||||||
end
|
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 {
|
return {
|
||||||
value = splitted[1],
|
value = stash_idx,
|
||||||
ordinal = splitted[3],
|
ordinal = commit_info,
|
||||||
display = splitted[3],
|
branch_name = branch_name,
|
||||||
|
commit_info = commit_info,
|
||||||
|
display = make_display,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user