Fix problem with filenames missing normalization
This commit is contained in:
parent
3634c212a9
commit
f17f5a4d6d
|
@ -89,17 +89,22 @@ command.add(nil, {
|
||||||
local view = core.active_view
|
local view = core.active_view
|
||||||
if view.doc and view.doc.abs_filename then
|
if view.doc and view.doc.abs_filename then
|
||||||
local dirname, filename = view.doc.abs_filename:match("(.*)[/\\](.+)$")
|
local dirname, filename = view.doc.abs_filename:match("(.*)[/\\](.+)$")
|
||||||
core.command_view:set_text(core.normalize_to_project_dir(dirname) .. PATHSEP)
|
if dirname then
|
||||||
|
dirname = core.normalize_to_project_dir(dirname)
|
||||||
|
local text = dirname == core.project_dir and "" or common.home_encode(dirname) .. PATHSEP
|
||||||
|
core.command_view:set_text(text)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
core.command_view:enter("Open File", function(text)
|
core.command_view:enter("Open File", function(text)
|
||||||
core.root_view:open_doc(core.open_doc(common.home_expand(text)))
|
local filename = system.absolute_path(common.home_expand(text))
|
||||||
|
core.root_view:open_doc(core.open_doc(filename))
|
||||||
end, function (text)
|
end, function (text)
|
||||||
return common.home_encode_list(common.path_suggest(common.home_expand(text)))
|
return common.home_encode_list(common.path_suggest(common.home_expand(text)))
|
||||||
end, nil, function(text)
|
end, nil, function(text)
|
||||||
local path_stat, err = system.get_file_info(common.home_expand(text))
|
local path_stat, err = system.get_file_info(common.home_expand(text))
|
||||||
if err then
|
if err then
|
||||||
core.error("Cannot open file %q: %q", text, err)
|
core.error("Cannot open file %q: %q", text, err)
|
||||||
elseif path_stat.type == 'dir' then
|
elseif path_stat.type == 'dir' then
|
||||||
core.error("Cannot open %q, is a folder", text)
|
core.error("Cannot open %q, is a folder", text)
|
||||||
else
|
else
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -206,7 +206,9 @@ end
|
||||||
function common.home_encode(text)
|
function common.home_encode(text)
|
||||||
if HOME and string.find(text, HOME, 1, true) == 1 then
|
if HOME and string.find(text, HOME, 1, true) == 1 then
|
||||||
local dir_pos = #HOME + 1
|
local dir_pos = #HOME + 1
|
||||||
if string.find(text, PATHSEP, dir_pos, true) == dir_pos then
|
-- ensure we don't replace if the text is just "$HOME" or "$HOME/" so
|
||||||
|
-- it must have a "/" following the $HOME and some characters following.
|
||||||
|
if string.find(text, PATHSEP, dir_pos, true) == dir_pos and #text > dir_pos then
|
||||||
return "~" .. text:sub(dir_pos)
|
return "~" .. text:sub(dir_pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue