Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
Francesco Abbate
2021-02-09 18:39:39 +01:00
4 changed files with 21 additions and 14 deletions
+8 -8
View File
@@ -37,8 +37,8 @@ local function normalize_path(s)
end
local function add_project_to_recents(dirname)
dirname = normalize_path(system.absolute_path(dirname))
local function add_project_to_recents(dir_path_abs)
local dirname = normalize_path(dir_path_abs)
if not dirname then return end
local recents = core.recent_projects
local n = #recents
@@ -74,11 +74,11 @@ function core.set_project_dir(new_dir, change_project_fn)
end
function core.open_folder_project(dirname)
if core.set_project_dir(dirname, core.on_quit_project) then
function core.open_folder_project(dir_path_abs)
if core.set_project_dir(dir_path_abs, core.on_quit_project) then
core.root_view:close_all_docviews()
add_project_to_recents(dirname)
core.on_enter_project(dirname)
add_project_to_recents(dir_path_abs)
core.on_enter_project(dir_path_abs)
end
end
@@ -381,7 +381,7 @@ function core.init()
local project_dir_abs = system.absolute_path(project_dir)
local set_project_ok = core.set_project_dir(project_dir_abs)
if set_project_ok then
add_project_to_recents(project_dir)
add_project_to_recents(project_dir_abs)
else
core.error("Cannot enter project directory %q", project_dir)
project_dir_abs = system.absolute_path(".")
@@ -460,7 +460,7 @@ end
function core.temp_filename(ext)
temp_file_counter = temp_file_counter + 1
return EXEDIR .. PATHSEP .. temp_file_prefix
return USERDIR .. PATHSEP .. temp_file_prefix
.. string.format("%06x", temp_file_counter) .. (ext or "")
end
+2 -1
View File
@@ -52,7 +52,8 @@ function ResultsView:begin_search(text, fn)
local i = 1
for dir_name, file in core.get_project_files() do
if file.type == "file" then
find_all_matches_in_file(self.results, dir_name .. PATHSEP .. file.filename, fn)
local path = (dir_name == core.project_dir and "" or (dir_name .. PATHSEP))
find_all_matches_in_file(self.results, path .. file.filename, fn)
end
self.last_file_idx = i
i = i + 1
+6 -2
View File
@@ -35,7 +35,11 @@ function TreeView:get_cached(item, dirname)
dir_cache = {}
self.cache[dirname] = dir_cache
end
local t = dir_cache[item.filename]
-- to discriminate top directories from regular files or subdirectories
-- we add ':' at the end of the top directories' filename. it will be
-- used only to identify the entry into the cache.
local cache_name = item.filename .. (item.topdir and ":" or "")
local t = dir_cache[cache_name]
if not t then
t = {}
local basename = common.basename(item.filename)
@@ -51,7 +55,7 @@ function TreeView:get_cached(item, dirname)
end
t.name = basename
t.type = item.type
dir_cache[item.filename] = t
dir_cache[cache_name] = t
end
return t
end