Skip to content

Commit f2b89ef

Browse files
committed
(mini.extra) Update pickers.oldfiles to use ~ instead of home directory.
1 parent e1f49ae commit f2b89ef

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lua/mini/extra.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,7 @@ H.full_path = function(path) return (vim.fn.fnamemodify(path, ':p'):gsub('(.)/$'
18651865

18661866
H.short_path = function(path, cwd)
18671867
cwd = cwd or vim.fn.getcwd()
1868-
if not vim.startswith(path, cwd) then return path end
1868+
if not vim.startswith(path, cwd) then return vim.fn.fnamemodify(path, ':~') end
18691869
local res = path:sub(cwd:len() + 1):gsub('^/+', ''):gsub('/+$', '')
18701870
return res
18711871
end

tests/test_extra.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2686,7 +2686,8 @@ T['pickers']['oldfiles()']['respects `opts.source.cwd`'] = function()
26862686
pick_oldfiles({}, { source = { cwd = real_files_dir } })
26872687
local items = get_picker_items()
26882688
eq(items[1], 'LICENSE')
2689-
expect.match(items[2], vim.pesc(ref_oldfiles[2]))
2689+
-- - For paths not from `cwd` it should shorten home directory to `~`
2690+
expect.match(items[2], vim.pesc(child.fn.fnamemodify(ref_oldfiles[2], ':~')))
26902691
end
26912692

26922693
T['pickers']['options()'] = new_set()

0 commit comments

Comments
 (0)