From 5f29cb8190dbee6bb10b4eb904c8c39750de352d Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Tue, 23 Nov 2010 19:09:21 -0500 Subject: Code cleanup. Also modified the editing module's enclose() and select_enclosed() functions. --- modules/textadept/session.lua | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) mode change 100755 => 100644 modules/textadept/session.lua (limited to 'modules/textadept/session.lua') diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua old mode 100755 new mode 100644 index c8fc1d90..745638cc --- 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 -- cgit v1.2.3