diff --git a/data/core/commands/core.lua b/data/core/commands/core.lua index 0acf1f86..31b45118 100644 --- a/data/core/commands/core.lua +++ b/data/core/commands/core.lua @@ -69,8 +69,7 @@ command.add(nil, { local files = {} for dir, item in core.get_project_files() do if item.type == "file" then - local path = (dir == core.project_dir and "" or dir .. PATHSEP) - table.insert(files, common.home_encode(path .. item.filename)) + table.insert(files, common.home_encode(dir .. PATHSEP .. item.filename)) end end core.command_view:enter("Open File From Project", function(text, item) diff --git a/data/core/commands/doc.lua b/data/core/commands/doc.lua index b1f3ebcb..e79aa6ab 100644 --- a/data/core/commands/doc.lua +++ b/data/core/commands/doc.lua @@ -68,10 +68,7 @@ end local function save(filename) - if filename then - filename = core.normalize_to_working_dir(filename) - end - doc():save(filename) + doc():save(filename and core.normalize_to_working_dir(filename)) local saved_filename = doc().filename core.on_doc_save(saved_filename) core.log("Saved \"%s\"", saved_filename) diff --git a/data/core/init.lua b/data/core/init.lua index ab067a85..846ef85d 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -668,6 +668,7 @@ end function core.set_visited(filename) + filename = common.home_encode(filename) for i = 1, #core.visited_files do if core.visited_files[i] == filename then table.remove(core.visited_files, i) @@ -721,16 +722,15 @@ function core.pop_clip_rect() renderer.set_clip_rect(x, y, w, h) end --- FIXME: update comment -- The function below works like system.absolute_path except it -- doesn't fail if the file does not exist. We consider that the --- current dir is core.project_dir so relative filename are considered --- to be in core.project_dir. +-- current dir is core.working_dir so relative filename are considered +-- to be in core.working_dir. -- Please note that .. or . in the filename are not taken into account. -- This function should get only filenames normalized using -- common.normalize_path function. function core.working_dir_absolute_path(filename) - if filename:match('^%a:\\') or filename:find('/', 1, true) then + if filename:match('^%a:\\') or filename:find('/', 1, true) == 1 then return filename else return core.working_dir .. PATHSEP .. filename