Merge pull request #705 from Guldoman/check_if_proj_dir
Check the entire path in `TreeView` predicate
This commit is contained in:
commit
2997aa2652
|
@ -406,7 +406,7 @@ function RootView:draw(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_project_folder(path)
|
local function is_project_folder(path)
|
||||||
return common.basename(core.project_dir) == path
|
return core.project_dir == path
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:register(function() return view.hovered_item end, {
|
menu:register(function() return view.hovered_item end, {
|
||||||
|
@ -417,7 +417,7 @@ menu:register(function() return view.hovered_item end, {
|
||||||
menu:register(
|
menu:register(
|
||||||
function()
|
function()
|
||||||
return view.hovered_item
|
return view.hovered_item
|
||||||
and not is_project_folder(view.hovered_item.filename)
|
and not is_project_folder(view.hovered_item.abs_filename)
|
||||||
end,
|
end,
|
||||||
{
|
{
|
||||||
{ text = "Rename", command = "treeview:rename" },
|
{ text = "Rename", command = "treeview:rename" },
|
||||||
|
@ -467,9 +467,8 @@ command.add(function() return view.hovered_item ~= nil end, {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["treeview:new-file"] = function()
|
["treeview:new-file"] = function()
|
||||||
local dir_name = view.hovered_item.filename
|
if not is_project_folder(view.hovered_item.abs_filename) then
|
||||||
if not is_project_folder(dir_name) then
|
core.command_view:set_text(view.hovered_item.filename .. "/")
|
||||||
core.command_view:set_text(dir_name .. "/")
|
|
||||||
end
|
end
|
||||||
core.command_view:enter("Filename", function(filename)
|
core.command_view:enter("Filename", function(filename)
|
||||||
local doc_filename = core.project_dir .. PATHSEP .. filename
|
local doc_filename = core.project_dir .. PATHSEP .. filename
|
||||||
|
@ -482,9 +481,8 @@ command.add(function() return view.hovered_item ~= nil end, {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["treeview:new-folder"] = function()
|
["treeview:new-folder"] = function()
|
||||||
local dir_name = view.hovered_item.filename
|
if not is_project_folder(view.hovered_item.abs_filename) then
|
||||||
if not is_project_folder(dir_name) then
|
core.command_view:set_text(view.hovered_item.filename .. "/")
|
||||||
core.command_view:set_text(dir_name .. "/")
|
|
||||||
end
|
end
|
||||||
core.command_view:enter("Folder Name", function(filename)
|
core.command_view:enter("Folder Name", function(filename)
|
||||||
local dir_path = core.project_dir .. PATHSEP .. filename
|
local dir_path = core.project_dir .. PATHSEP .. filename
|
||||||
|
|
Loading…
Reference in New Issue