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:
Adam authored and GitHub committed 2021-05-05 08:04:51 +02:00
1 parent fa99d5401e
commit 4c42dd4adc
2 files changed
+17 -4

No files matched your search

+9
View File
@@ -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,