Skip to content

Commit 591b5b2

Browse files
zgondalzgondal
andauthored
Fix hyper theme showing empty mru_list if cwd_only set to true (#510)
Co-authored-by: zgondal <[email protected]>
1 parent 91891ff commit 591b5b2

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lua/dashboard/theme/hyper.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,13 @@ local function mru_list(config)
190190

191191
if config.mru.cwd_only then
192192
local cwd = uv.cwd()
193-
-- get separator from the first file
194-
local sep = mlist[1]:match('[\\/]')
195-
local cwd_with_sep = cwd:gsub('[\\/]', sep) .. sep
193+
-- Normalize both paths to use forward slashes
194+
cwd = vim.fn.fnamemodify(cwd, ':p')
196195
mlist = vim.tbl_filter(function(file)
197-
local file_dir = vim.fn.fnamemodify(file, ':p:h')
198-
if file_dir and cwd_with_sep then
199-
return file_dir:sub(1, #cwd_with_sep) == cwd_with_sep
200-
end
196+
local file_path = vim.fn.fnamemodify(file, ':p')
197+
local file_dir = vim.fn.fnamemodify(file_path, ':h') .. '/'
198+
-- Ensure both paths end with separator and are normalized
199+
return file_dir:sub(1, #cwd) == cwd
201200
end, mlist)
202201
end
203202

0 commit comments

Comments
 (0)