aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/session.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2010-03-25 06:31:16 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2010-03-25 06:31:16 -0400
commit9583dadb72798bddcf14260d263a2b3b9ac451a3 (patch)
tree0b949e1939c4c6d5e7b5e9bd49a66bb53b91708c /modules/textadept/session.lua
parent67fdad16ebd8874420fd95e8329070dfe4f78e47 (diff)
downloadtextadept-9583dadb72798bddcf14260d263a2b3b9ac451a3.tar.gz
textadept-9583dadb72798bddcf14260d263a2b3b9ac451a3.zip
Added notification for session files not found.
Diffstat (limited to 'modules/textadept/session.lua')
-rw-r--r--modules/textadept/session.lua16
1 files changed, 15 insertions, 1 deletions
diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua
index a867ddf5..ed1cbe8e 100644
--- a/modules/textadept/session.lua
+++ b/modules/textadept/session.lua
@@ -20,6 +20,8 @@ DEFAULT_SESSION = _USERHOME..'/session'
SAVE_ON_QUIT = true
-- end settings
+local lfs = require 'lfs'
+
---
-- Loads a Textadept session file.
-- Textadept restores split views, opened buffers, cursor information, and
@@ -29,6 +31,7 @@ SAVE_ON_QUIT = true
-- @return true if the session file was opened and read; false otherwise.
-- @usage _m.textadept.session.load(filename)
function load(filename)
+ local not_found = {}
local f = io.open(filename or DEFAULT_SESSION, 'rb')
if not f then
if not textadept.io.close_all() then return false end
@@ -40,7 +43,11 @@ function load(filename)
local anchor, current_pos, first_visible_line, filename =
line:match('^buffer: (%d+) (%d+) (%d+) (.+)$')
if not filename:find('^%[.+%]$') then
- textadept.io.open(filename or '')
+ if lfs.attributes(filename) then
+ textadept.io.open(filename)
+ else
+ not_found[#not_found + 1] = filename
+ end
else
textadept.new_buffer()
buffer._type = filename
@@ -79,6 +86,13 @@ function load(filename)
f:close()
textadept.views[current_view]:focus()
textadept.session_file = filename or DEFAULT_SESSION
+ if #not_found > 0 then
+ textadept.dialog('msgbox',
+ '--title', locale.M_SESSION_FILES_NOT_FOUND_TITLE,
+ '--text', locale.M_SESSION_FILES_NOT_FOUND_TEXT,
+ '--informative-text',
+ string.format('%s', table.concat(not_found, '\n')))
+ end
return true
end