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 <joshuapaulpiasecki@gmail.com>
Co-authored-by: Takase <20792268+takase1121@users.noreply.github.com>
This commit is contained in:
Josh Piasecki
2024-12-04 13:02:06 +08:00
committed by takase1121
co-authored by Takase FloppyDisco
parent 9222136070
commit d436dfe9bf
+10
View File
@@ -746,7 +746,12 @@ command.add(
["treeview:new-file"] = function(item) ["treeview:new-file"] = function(item)
local text local text
if not is_project_folder(item.abs_filename) then if not is_project_folder(item.abs_filename) then
if item.type == "dir" then
text = item.filename .. PATHSEP 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 end
core.command_view:enter("Filename", { core.command_view:enter("Filename", {
text = text, text = text,
@@ -768,7 +773,12 @@ command.add(
["treeview:new-folder"] = function(item) ["treeview:new-folder"] = function(item)
local text local text
if not is_project_folder(item.abs_filename) then if not is_project_folder(item.abs_filename) then
if item.type == "dir" then
text = item.filename .. PATHSEP 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 end
core.command_view:enter("Folder Name", { core.command_view:enter("Folder Name", {
text = text, text = text,