Do not close command view on open-file is file is invalid or it is a directory
Added in a validation function which fires before submitting a command enter; found it incredibly irritating to try to open something, hit enter, only to be told I'd selected a directory, and then have to go through the whole process again. (#175)
This commit is contained in:
@@ -94,6 +94,15 @@ command.add(nil, {
|
||||
core.root_view:open_doc(core.open_doc(common.home_expand(text)))
|
||||
end, function (text)
|
||||
return common.home_encode_list(common.path_suggest(common.home_expand(text)))
|
||||
end, nil, function(text)
|
||||
local path_stat, err = system.get_file_info(common.home_expand(text))
|
||||
if err then
|
||||
core.error("Cannot open file %q: %q", text, err)
|
||||
elseif path_stat.type == 'dir' then
|
||||
core.error("Cannot open %q, is a folder", text)
|
||||
else
|
||||
return true
|
||||
end
|
||||
end)
|
||||
end,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user