aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/session.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2010-11-23 19:09:21 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2010-11-23 19:09:21 -0500
commit5f29cb8190dbee6bb10b4eb904c8c39750de352d (patch)
treeef9d178b4834087d829702d4894ec3b9330f3c0b /modules/textadept/session.lua
parent1f3bbef0357b89f82a65d1e67caa1980eee3f40b (diff)
downloadtextadept-5f29cb8190dbee6bb10b4eb904c8c39750de352d.tar.gz
textadept-5f29cb8190dbee6bb10b4eb904c8c39750de352d.zip
Code cleanup.
Also modified the editing module's enclose() and select_enclosed() functions.
Diffstat (limited to 'modules/textadept/session.lua')
-rw-r--r--[-rwxr-xr-x]modules/textadept/session.lua12
1 files changed, 5 insertions, 7 deletions
diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua
index c8fc1d90..745638cc 100755..100644
--- a/modules/textadept/session.lua
+++ b/modules/textadept/session.lua
@@ -19,8 +19,6 @@ 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
@@ -33,16 +31,17 @@ function load(filename)
local not_found = {}
local f = io.open(filename or DEFAULT_SESSION, 'rb')
if not f then
- if not io.close_all() then return false end
+ io.close_all()
+ return false
end
- if not f then return false end
local current_view, splits = 1, { [0] = {} }
+ local lfs_attributes = lfs.attributes
for line in f:lines() do
if line:find('^buffer:') then
local anchor, current_pos, first_visible_line, filename =
line:match('^buffer: (%d+) (%d+) (%d+) (.+)$')
if not filename:find('^%[.+%]$') then
- if lfs.attributes(filename) then
+ if lfs_attributes(filename) then
io.open_file(filename)
else
not_found[#not_found + 1] = filename
@@ -77,8 +76,7 @@ function load(filename)
elseif line:find('^current_view:') then
local view_idx = line:match('^current_view: (%d+)')
current_view = tonumber(view_idx) or 1
- end
- if line:find('^size:') then
+ elseif line:find('^size:') then
local width, height = line:match('^size: (%d+) (%d+)$')
if width and height then gui.size = { width, height } end
end