From a4100a8512968dfa4eb39b74942a0ede1cb9b75c Mon Sep 17 00:00:00 2001 From: adriankarlen Date: Sat, 22 Jun 2024 18:29:46 +0200 Subject: [PATCH 1/5] fix(hyper): use backslash when user has shellslash enabled on windows --- lua/dashboard/theme/hyper.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/dashboard/theme/hyper.lua b/lua/dashboard/theme/hyper.lua index 3f99f22..57fc57e 100644 --- a/lua/dashboard/theme/hyper.lua +++ b/lua/dashboard/theme/hyper.lua @@ -175,7 +175,7 @@ local function mru_list(config) if config.mru.cwd_only then local cwd = uv.cwd() - local sep = utils.is_win and '\\' or '/' + local sep = (utils.is_win and not vim.o.shellslash) and '\\' or '/' local cwd_with_sep = cwd .. sep mlist = vim.tbl_filter(function(file) local file_dir = vim.fn.fnamemodify(file, ':p:h') .. sep From 1aa9852b61325a47852bf54523bafa07b8cafeea Mon Sep 17 00:00:00 2001 From: adriankarlen Date: Sat, 22 Jun 2024 18:33:25 +0200 Subject: [PATCH 2/5] fix: test wit use explicitly --- lua/dashboard/theme/hyper.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/dashboard/theme/hyper.lua b/lua/dashboard/theme/hyper.lua index 57fc57e..d2c2cef 100644 --- a/lua/dashboard/theme/hyper.lua +++ b/lua/dashboard/theme/hyper.lua @@ -175,7 +175,7 @@ local function mru_list(config) if config.mru.cwd_only then local cwd = uv.cwd() - local sep = (utils.is_win and not vim.o.shellslash) and '\\' or '/' + local sep = '/' local cwd_with_sep = cwd .. sep mlist = vim.tbl_filter(function(file) local file_dir = vim.fn.fnamemodify(file, ':p:h') .. sep From 76ad5a3f1833b427fccf2b9d186c9c55f386fbc9 Mon Sep 17 00:00:00 2001 From: adriankarlen Date: Sat, 22 Jun 2024 19:01:03 +0200 Subject: [PATCH 3/5] fix: handle backslash and slash regardless of os --- lua/dashboard/theme/hyper.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lua/dashboard/theme/hyper.lua b/lua/dashboard/theme/hyper.lua index d2c2cef..0e10fad 100644 --- a/lua/dashboard/theme/hyper.lua +++ b/lua/dashboard/theme/hyper.lua @@ -174,13 +174,11 @@ local function mru_list(config) local mlist = utils.get_mru_list() if config.mru.cwd_only then - local cwd = uv.cwd() - local sep = '/' - local cwd_with_sep = cwd .. sep + local cwd_filtered = uv.cwd():gsub('[\\/]', '') mlist = vim.tbl_filter(function(file) - local file_dir = vim.fn.fnamemodify(file, ':p:h') .. sep - if file_dir and cwd then - return file_dir:sub(1, #cwd_with_sep) == cwd_with_sep + local file_dir_filtered = vim.fn.fnamemodify(file, ':p:h'):gsub('[\\/]', '') + if file_dir_filtered and cwd_filtered then + return file_dir_filtered:find(cwd_filtered, 1, true) == 1 end end, mlist) end From 6fc2e0d348009af68b8ea2cc82f1c760aebb2360 Mon Sep 17 00:00:00 2001 From: adriankarlen Date: Sat, 22 Jun 2024 23:29:08 +0200 Subject: [PATCH 4/5] fix(hyper): use correct matching method --- lua/dashboard/theme/hyper.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/dashboard/theme/hyper.lua b/lua/dashboard/theme/hyper.lua index 0e10fad..55bc793 100644 --- a/lua/dashboard/theme/hyper.lua +++ b/lua/dashboard/theme/hyper.lua @@ -178,7 +178,7 @@ local function mru_list(config) mlist = vim.tbl_filter(function(file) local file_dir_filtered = vim.fn.fnamemodify(file, ':p:h'):gsub('[\\/]', '') if file_dir_filtered and cwd_filtered then - return file_dir_filtered:find(cwd_filtered, 1, true) == 1 + return file_dir_filtered:sub(1, #cwd_filtered) == cwd_filtered end end, mlist) end From 5990e85fdd2d76f45fcd11d9b48021b5cd4280de Mon Sep 17 00:00:00 2001 From: adriankarlen Date: Sat, 22 Jun 2024 23:47:36 +0200 Subject: [PATCH 5/5] fix(hyper): extract sep from mlist --- lua/dashboard/theme/hyper.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lua/dashboard/theme/hyper.lua b/lua/dashboard/theme/hyper.lua index 55bc793..4e09fae 100644 --- a/lua/dashboard/theme/hyper.lua +++ b/lua/dashboard/theme/hyper.lua @@ -174,11 +174,14 @@ local function mru_list(config) local mlist = utils.get_mru_list() if config.mru.cwd_only then - local cwd_filtered = uv.cwd():gsub('[\\/]', '') + local cwd = uv.cwd() + -- get separator from the first file + local sep = mlist[1]:match('[\\/]') + local cwd_with_sep = cwd:gsub('[\\/]', sep) .. sep mlist = vim.tbl_filter(function(file) - local file_dir_filtered = vim.fn.fnamemodify(file, ':p:h'):gsub('[\\/]', '') - if file_dir_filtered and cwd_filtered then - return file_dir_filtered:sub(1, #cwd_filtered) == cwd_filtered + local file_dir = vim.fn.fnamemodify(file, ':p:h') + if file_dir and cwd_with_sep then + return file_dir:sub(1, #cwd_with_sep) == cwd_with_sep end end, mlist) end