From d436dfe9bff8d8d3d4940ae3ce110d23231ecf96 Mon Sep 17 00:00:00 2001 From: Josh Piasecki <138541977+FloppyDisco@users.noreply.github.com> Date: Mon, 2 Dec 2024 08:38:06 +0100 Subject: [PATCH] check item type before creating input text (#1904) * check item type before creating input text * Update data/plugins/treeview.lua Co-authored-by: Takase <20792268+takase1121@users.noreply.github.com> * Update data/plugins/treeview.lua Co-authored-by: Takase <20792268+takase1121@users.noreply.github.com> --------- Co-authored-by: FloppyDisco Co-authored-by: Takase <20792268+takase1121@users.noreply.github.com> --- data/plugins/treeview.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/data/plugins/treeview.lua b/data/plugins/treeview.lua index 34c087a..00801fd 100644 --- a/data/plugins/treeview.lua +++ b/data/plugins/treeview.lua @@ -746,7 +746,12 @@ command.add( ["treeview:new-file"] = function(item) local text if not is_project_folder(item.abs_filename) then - text = item.filename .. PATHSEP + if item.type == "dir" then + text = item.filename .. PATHSEP + elseif item.type == "file" then + local parent_dir = common.dirname(item.filename) + text = parent_dir and parent_dir .. PATHSEP + end end core.command_view:enter("Filename", { text = text, @@ -768,7 +773,12 @@ command.add( ["treeview:new-folder"] = function(item) local text if not is_project_folder(item.abs_filename) then - text = item.filename .. PATHSEP + if item.type == "dir" then + text = item.filename .. PATHSEP + elseif item.type == "file" then + local parent_dir = common.dirname(item.filename) + text = parent_dir and parent_dir .. PATHSEP + end end core.command_view:enter("Folder Name", { text = text,