From ed192326b8f6c89cfb5fba51fb185cbfc723fa43 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Thu, 8 Dec 2016 21:43:45 -0500 Subject: Prevent duplicate recent files on session load; modules/textadept/session.lua --- modules/textadept/session.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua index 11515de0..89ee042c 100644 --- a/modules/textadept/session.lua +++ b/modules/textadept/session.lua @@ -88,7 +88,12 @@ function M.load(filename) elseif line:find('^current_view:') then current_view = _VIEWS[tonumber(line:match('^current_view: (%d+)')) or 1] elseif line:find('^recent:') then - io.recent_files[#io.recent_files + 1] = line:match('^recent: (.+)$') + -- If a recent file is already open, do not add it to the list again. + local recent_file, exists = line:match('^recent: (.+)$'), false + for i = 1, #io.recent_files do + if io.recent_files[i] == recent_file then exists = true break end + end + if not exists then io.recent_files[#io.recent_files + 1] = recent_file end end end f:close() -- cgit v1.2.3