aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/session.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2015-03-16 16:55:12 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2015-03-16 16:55:12 -0400
commit39b5f8728fdd215217d2749c20a2668ecbb5f080 (patch)
tree603e845b6683f6725593c8f12e69183156b6c5c2 /modules/textadept/session.lua
parentcb3e886bba78a040d486af518d491cc191cebfd8 (diff)
downloadtextadept-39b5f8728fdd215217d2749c20a2668ecbb5f080.tar.gz
textadept-39b5f8728fdd215217d2749c20a2668ecbb5f080.zip
Code cleanup based on the output of luacheck, a Lua linter.
Diffstat (limited to 'modules/textadept/session.lua')
-rw-r--r--modules/textadept/session.lua29
1 files changed, 14 insertions, 15 deletions
diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua
index eabbb26d..1986e9d3 100644
--- a/modules/textadept/session.lua
+++ b/modules/textadept/session.lua
@@ -49,16 +49,16 @@ function M.load(filename)
for line in f:lines() do
if line:find('^buffer:') then
local patt = '^buffer: (%d+) (%d+) (%d+) (.+)$'
- local anchor, current_pos, first_visible_line, filename = line:match(patt)
- if not filename:find('^%[.+%]$') then
- if lfs_attributes(filename) then
- io.open_file(filename)
+ local anchor, current_pos, first_visible_line, file = line:match(patt)
+ if not file:find('^%[.+%]$') then
+ if lfs_attributes(file) then
+ io.open_file(file)
else
- not_found[#not_found + 1] = filename
+ not_found[#not_found + 1] = file
end
else
- buffer.new()._type = filename
- events.emit(events.FILE_OPENED, filename)
+ buffer.new()._type = file
+ events.emit(events.FILE_OPENED, file)
end
-- Restore saved buffer selection and view.
anchor, current_pos = tonumber(anchor) or 0, tonumber(current_pos) or 0
@@ -85,12 +85,12 @@ function M.load(filename)
ui.maximized = maximized == 'true'
if not ui.maximized then ui.size = {width, height} end
elseif line:find('^recent:') then
- local filename = line:match('^recent: (.+)$')
+ local file = line:match('^recent: (.+)$')
local recent, exists = io.recent_files, false
- for i, file in ipairs(recent) do
- if filename == file then exists = true break end
+ for i = 1, #recent do
+ if file == recent[i] then exists = true break end
end
- if not exists then recent[#recent + 1] = filename end
+ if not exists then recent[#recent + 1] = file end
end
end
f:close()
@@ -131,16 +131,15 @@ function M.save(filename)
local view_line = "%sview%d: %d" -- level, number, doc index
-- Write out opened buffers.
for _, buffer in ipairs(_BUFFERS) do
- local filename = buffer.filename or buffer._type
- if filename then
+ local file = buffer.filename or buffer._type
+ if file then
local current = buffer == view.buffer
local anchor = current and 'anchor' or '_anchor'
local current_pos = current and 'current_pos' or '_current_pos'
local top_line = current and 'first_visible_line' or '_first_visible_line'
session[#session + 1] = buffer_line:format(buffer[anchor] or 0,
buffer[current_pos] or 0,
- buffer[top_line] or 0,
- filename)
+ buffer[top_line] or 0, file)
end
end
-- Write out split views.