diff options
| author | Farbod Salamat-Zadeh <12140044+farbodsz@users.noreply.github.com> | 2021-12-06 20:20:37 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-06 21:20:37 +0100 |
| commit | 6b1579741a0e8f1e0e63d0c6c364b968c157338e (patch) | |
| tree | 297e1c6df710d2fb16e716b76a9c3d482728ed88 /lua/telescope/make_entry.lua | |
| parent | a20f01353bde239e931c3c461fd3ef2d160a4f9b (diff) | |
fix: git stash entry formatting (#1452)
Diffstat (limited to 'lua/telescope/make_entry.lua')
| -rw-r--r-- | lua/telescope/make_entry.lua | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 18da57a..1e48c8c 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -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 |
