Fix a few things
This commit is contained in:
parent
ef4ad10326
commit
3ccfb94107
|
@ -536,7 +536,7 @@ function core.init()
|
|||
end)
|
||||
end
|
||||
|
||||
if #core.docs == 0 then
|
||||
if #core.project_entries == 0 then
|
||||
local ws = core.try(project.load_workspace, USERDIR .. PATHSEP .. "workspace.lua")
|
||||
if not ws then
|
||||
core.log("Empty project: use the \"Core: Open File\" command to open a file or a directory.")
|
||||
|
|
|
@ -105,7 +105,7 @@ keymap.add_direct {
|
|||
["ctrl+p"] = "core:find-file",
|
||||
["ctrl+o"] = "core:open-file",
|
||||
["ctrl+n"] = "core:new-doc",
|
||||
["ctrl+shift+c"] = "core:change-project-folder",
|
||||
["ctrl+shift+c"] = "project:open-directory",
|
||||
["ctrl+shift+o"] = "core:open-project-folder",
|
||||
["alt+return"] = "core:toggle-fullscreen",
|
||||
|
||||
|
|
|
@ -139,6 +139,14 @@ function project.load(name)
|
|||
end
|
||||
|
||||
|
||||
function project.save(name)
|
||||
name = name or core.project_name
|
||||
local filename = common.path_join(USERDIR, "projects", name .. ".lua")
|
||||
save_workspace(filename)
|
||||
core.log("Saved project %s.", core.project_name)
|
||||
end
|
||||
|
||||
|
||||
function project.load_workspace(filename)
|
||||
local load = loadfile(filename)
|
||||
local workspace = load and load()
|
||||
|
@ -177,9 +185,7 @@ command.add(nil, {
|
|||
core.command_view:enter("Save Project As", function(text)
|
||||
-- FIXME: add sanity check of project name.
|
||||
core.project_name = text
|
||||
local filename = common.path_join(USERDIR, "projects", text .. ".lua")
|
||||
save_workspace(filename)
|
||||
core.log("Saved project %s.", core.project_name)
|
||||
project.save()
|
||||
end)
|
||||
end,
|
||||
|
||||
|
@ -189,10 +195,7 @@ command.add(nil, {
|
|||
core.project_name = text
|
||||
end)
|
||||
end
|
||||
local filename = common.path_join(USERDIR, "projects", core.project_name .. ".lua")
|
||||
save_workspace(filename)
|
||||
core.set_recent_project(core.project_name)
|
||||
core.log("Saved project %s.", core.project_name)
|
||||
project.save()
|
||||
end,
|
||||
|
||||
["project:load"] = function()
|
||||
|
@ -205,7 +208,6 @@ command.add(nil, {
|
|||
["project:open-directory"] = function()
|
||||
core.command_view:enter("Open Directory", function(text, item)
|
||||
text = system.absolute_path(common.home_expand(item and item.text or text))
|
||||
if text == core.working_dir then return end
|
||||
local path_stat = system.get_file_info(text)
|
||||
if not path_stat or path_stat.type ~= 'dir' then
|
||||
core.error("Cannot open folder %q", text)
|
||||
|
|
Loading…
Reference in New Issue