Skip to content

Commit 96a45f3

Browse files
authored
fix: error opening recent projects (#418)
1 parent c045eb2 commit 96a45f3

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

lua/dashboard/theme/hyper.lua

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,18 +281,25 @@ end
281281
local function map_key(config, key, content)
282282
keymap.set('n', key, function()
283283
local text = content or api.nvim_get_current_line()
284+
local scol = utils.is_win and text:find('%w') or text:find('%p')
285+
local path = nil
286+
287+
if scol ~= nil then
288+
local is_tilde = text:sub(scol, scol) == '~'
289+
290+
if not is_tilde then
291+
scol = text:find('%w')
292+
end
284293

285-
if config.mru.cwd_only then
286-
local scol = text:find(' %w')
287-
text = text:sub(scol)
288-
else
289-
local scol = utils.is_win and text:find('%w') or text:find('%p')
290294
text = text:sub(scol)
295+
296+
path = text:sub(1, text:find('%w(%s+)$'))
297+
path = vim.fs.normalize(path)
291298
end
292299

293-
local path = text:sub(1, text:find('%w(%s+)$'))
294-
path = vim.fs.normalize(path)
295-
if vim.fn.isdirectory(path) == 1 then
300+
if path == nil then
301+
vim.cmd('enew')
302+
elseif vim.fn.isdirectory(path) == 1 then
296303
vim.cmd('lcd ' .. path)
297304
if type(config.project.action) == 'function' then
298305
config.project.action(path)

0 commit comments

Comments
 (0)