Skip to content

Commit

Permalink
Revert "New-File ending in slash creates new folder instead (lite-xl#…
Browse files Browse the repository at this point in the history
…1898)"

This reverts commit e4ceefe.
  • Loading branch information
Guldoman committed Dec 3, 2024
1 parent 36db156 commit bef4a42
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions data/plugins/treeview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -772,19 +772,6 @@ command.add(
end
})

local function create_new_file(filename)
core.log(filename)
local file = io.open(filename, "a+")
file:write("")
file:close()
core.root_view:open_doc(core.open_doc(filename))
core.log("Created %s", filename)
end

local function create_new_folder(dir_path)
common.mkdirp(dir_path)
core.log("Created %s", dir_path)
end

command.add(
function()
Expand Down Expand Up @@ -877,12 +864,12 @@ command.add(
text = text,
submit = function(filename)
local doc_filename = item.dir_name .. PATHSEP .. filename
local lastChar = filename:sub(#filename)
if lastChar == "/" or lastChar == "\\" then
create_new_folder(filename)
else
create_new_file(doc_filename)
end
core.log(doc_filename)
local file = io.open(doc_filename, "a+")
file:write("")
file:close()
view:open_doc(doc_filename)
core.log("Created %s", doc_filename)
end,
suggest = function(text)
return common.path_suggest(text, item.dir_name)
Expand All @@ -904,7 +891,8 @@ command.add(
text = text,
submit = function(filename)
local dir_path = item.dir_name .. PATHSEP .. filename
create_new_folder(dir_path)
common.mkdirp(dir_path)
core.log("Created %s", dir_path)
end,
suggest = function(text)
return common.path_suggest(text, item.dir_name)
Expand Down

0 comments on commit bef4a42

Please sign in to comment.