summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFasamii <fasami0512@gmail.com>2026-02-09 00:24:48 +0100
committerFasamii <fasami0512@gmail.com>2026-02-09 00:24:48 +0100
commit4f68dab62e77ce7f0b4bf2164634942dd6101312 (patch)
tree25caa0e9d8adf2a0ed0c31952987a6a1d69e1a24
parentca7c9de0ee9cf584eadf7100d0c95c9eabafd451 (diff)
downloadnetrw-icons.nvim-4f68dab62e77ce7f0b4bf2164634942dd6101312.tar.gz
netrw-icons.nvim-4f68dab62e77ce7f0b4bf2164634942dd6101312.tar.bz2
netrw-icons.nvim-4f68dab62e77ce7f0b4bf2164634942dd6101312.tar.xz
netrw-icons.nvim-4f68dab62e77ce7f0b4bf2164634942dd6101312.tar.zst
parse_liststyle_3 early returns
-rw-r--r--lua/netrw-icons/parse.lua24
1 files changed, 12 insertions, 12 deletions
diff --git a/lua/netrw-icons/parse.lua b/lua/netrw-icons/parse.lua
index fbd9da1..cd7ba79 100644
--- a/lua/netrw-icons/parse.lua
+++ b/lua/netrw-icons/parse.lua
@@ -79,38 +79,38 @@ end
---@param line string
---@return rwNode|nil
local parse_liststyle_3 = function(line)
- local current_dir = vim.b.netrw_curdir;
- local type = M.TYPE_FILE;
+ local node = {};
+ node.type = M.TYPE_FILE;
local _, tree_end = string.find(line, "^[|%s]*");
+ node.icon = tree_end;
local content = string.sub(line, tree_end + 1, #line);
if content == "" then
return nil;
end
- local name = content;
+ node.name = content;
- if name:sub(-1) == "*" then
- type = M.TYPE_EXE;
+ if node.name:sub(-1) == "*" then
+ node.type = M.TYPE_EXE;
+ return node;
end
local _, _, link, link_target = string.find(content, "^(.+)@\t%s*%-%->%s*(.+)")
if link then
- type = M.TYPE_SYMLINK;
- name = link_target;
+ node.type = M.TYPE_SYMLINK;
+ node.name = link_target;
+ return node;
end
local _, _, dir = string.find(content, "^(.*)/")
if dir then
type = M.TYPE_DIR;
+ return node;
end
- return {
- name = name,
- icon = tree_end,
- type = type,
- }
+ return node;
end
---@param line string