From 03c4016d07477781aa3adcc9edf340c0bec9c6c8 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+orbitalquark@users.noreply.github.com> Date: Tue, 20 Oct 2020 15:29:03 -0400 Subject: Code cleanup. Of note: * io.save_all_files() does not visit each buffer to save anymore. An unintended side-effect was checking for outside modification (but only if the file itself was modified), so outside changes will always be saved over now. * The menu clicked handler uses assert_type(), so the 'Unknown command' localization is no longer needed. * When printing to a new buffer type would split the view, use an existing split view when possible. * Prefer 'goto continue' construct in loops over nested 'if's. * Fixed clearing of ui.find.replace_entry_text on reset in the GUI version. * Fixed lack of statusbar updating when setting options like buffer EOL mode, indentation, and encoding. * Renamed internal new_snippet() to new() and put it in the snippet metatable. --- modules/textadept/session.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'modules/textadept/session.lua') diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua index 7083c991..55a33be8 100644 --- a/modules/textadept/session.lua +++ b/modules/textadept/session.lua @@ -29,7 +29,8 @@ module('textadept.session')]] M.save_on_quit = true -- Events. -events.SESSION_SAVE, events.SESSION_LOAD = 'session_save', 'session_load' +local session_events = {'session_save', 'session_load'} +for _, v in ipairs(session_events) do events[v:upper()] = v end local session_file = _USERHOME .. (not CURSES and '/session' or '/session_term') @@ -51,7 +52,6 @@ function M.load(filename) } if not filename then return end end - local f = loadfile(filename, 't', {}) if not f or not io.close_all_buffers() then return end -- fail silently local session = f() @@ -86,12 +86,12 @@ function M.load(filename) local function unserialize_split(split) if type(split) ~= 'table' then view:goto_buffer(_BUFFERS[math.min(split, #_BUFFERS)]) - return - end - for i, view in ipairs{view:split(split.vertical)} do - view.size = split.size - ui.goto_view(view) - unserialize_split(split[i]) + else + for i, view in ipairs{view:split(split.vertical)} do + view.size = split.size + ui.goto_view(view) + unserialize_split(split[i]) + end end end unserialize_split(session.views[1]) -- cgit v1.2.3