Made lite set project dir to CWD; removed core.project_dir

Fixes #100
This commit is contained in:
rxi
2020-05-17 17:05:56 +01:00
parent c1f731e5a1
commit 4ae0d477c0
4 changed files with 21 additions and 15 deletions
+3 -3
View File
@@ -56,13 +56,13 @@ command.add(nil, {
["core:file-finder"] = function()
core.command_view:enter("Open File From Project", function(text, item)
text = core.project_dir .. PATHSEP .. (item and item.text or text)
text = item and item.text or text
core.root_view:open_doc(core.open_doc(text))
end, function(text)
local files = {}
for _, item in pairs(core.project_files) do
if item.type == "file" then
table.insert(files, item.filename:sub(#core.project_dir + 2))
table.insert(files, item.filename)
end
end
return common.fuzzy_match(files, text)
@@ -89,7 +89,7 @@ command.add(nil, {
end,
["core:open-project-module"] = function()
local filename = core.project_dir .. "/.lite_project.lua"
local filename = ".lite_project.lua"
if system.get_file_info(filename) then
core.root_view:open_doc(core.open_doc(filename))
else
+6 -9
View File
@@ -36,7 +36,7 @@ local function project_scan_thread()
for _, file in ipairs(all) do
if not common.match_pattern(file, config.ignore_files) then
local file = path .. PATHSEP .. file
local file = (path ~= "." and path .. PATHSEP or "") .. file
local info = system.get_file_info(file)
if info and info.size < size_limit then
info.filename = file
@@ -62,7 +62,7 @@ local function project_scan_thread()
while true do
-- get project files and replace previous table if the new table is
-- different
local t = get_files(core.project_dir)
local t = get_files(".")
if diff_files(core.project_files, t) then
core.project_files = t
core.redraw = true
@@ -88,12 +88,6 @@ function core.init()
core.docs = {}
core.threads = setmetatable({}, { __mode = "k" })
core.project_files = {}
core.project_dir = "."
local info = ARGS[2] and system.get_file_info(ARGS[2])
if info and info.type == "dir" then
core.project_dir = ARGS[2]:gsub("[\\/]$", "")
end
core.root_view = RootView()
core.command_view = CommandView()
@@ -120,6 +114,9 @@ function core.init()
if got_plugin_error or got_user_error or got_project_error then
command.perform("core:open-log")
end
local info = ARGS[2] and system.get_file_info(ARGS[2])
system.chdir(info and info.type == "dir" and ARGS[2] or ".")
end
@@ -166,7 +163,7 @@ end
function core.load_project_module()
local filename = core.project_dir .. "/.lite_project.lua"
local filename = ".lite_project.lua"
if system.get_file_info(filename) then
return core.try(function()
local fn, err = loadfile(filename)