@@ -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
@@ -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)
|
||||
|
||||
@@ -35,7 +35,7 @@ function TreeView:get_cached(item)
|
||||
t = {}
|
||||
t.filename = item.filename
|
||||
t.abs_filename = system.absolute_path(item.filename)
|
||||
t.path, t.name = t.filename:match("^(.*)[\\/](.+)$")
|
||||
t.name = t.filename:match("[^\\/]+$")
|
||||
t.depth = get_depth(t.filename)
|
||||
t.type = item.type
|
||||
self.cache[t.filename] = t
|
||||
@@ -143,7 +143,6 @@ function TreeView:draw()
|
||||
|
||||
local icon_width = style.icon_font:get_width("D")
|
||||
local spacing = style.font:get_width(" ") * 2
|
||||
local root_depth = get_depth(core.project_dir) + 1
|
||||
|
||||
local doc = core.active_view.doc
|
||||
local active_filename = doc and system.absolute_path(doc.filename or "")
|
||||
@@ -163,7 +162,7 @@ function TreeView:draw()
|
||||
end
|
||||
|
||||
-- icons
|
||||
x = x + (item.depth - root_depth) * style.padding.x + style.padding.x
|
||||
x = x + item.depth * style.padding.x + style.padding.x
|
||||
if item.type == "dir" then
|
||||
local icon1 = item.expanded and "-" or "+"
|
||||
local icon2 = item.expanded and "D" or "d"
|
||||
|
||||
Reference in New Issue
Block a user