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