Fix a few more things about filenames
This commit is contained in:
parent
2aac1b8179
commit
82231dbc98
|
@ -72,8 +72,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)
|
||||
|
|
|
@ -41,10 +41,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)
|
||||
|
|
|
@ -745,6 +745,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)
|
||||
|
@ -798,16 +799,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
|
||||
|
|
Loading…
Reference in New Issue