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/bookmarks.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'modules/textadept/bookmarks.lua') diff --git a/modules/textadept/bookmarks.lua b/modules/textadept/bookmarks.lua index c21f5dc4..de6f7470 100644 --- a/modules/textadept/bookmarks.lua +++ b/modules/textadept/bookmarks.lua @@ -28,10 +28,10 @@ function M.clear() buffer:marker_delete_all(M.MARK_BOOKMARK) end -- Returns an iterator for all bookmarks in the given buffer. local function bookmarks(buffer) - return function(_, line) + return function(buffer, line) line = buffer:marker_next(line + 1, 1 << M.MARK_BOOKMARK - 1) return line >= 1 and line or nil - end, nil, 0 + end, buffer, 0 end --- @@ -46,17 +46,17 @@ end function M.goto_mark(next) if next ~= nil then local f = next and buffer.marker_next or buffer.marker_previous - local current_line = buffer:line_from_position(buffer.current_pos) + local line = buffer:line_from_position(buffer.current_pos) local BOOKMARK_BIT = 1 << M.MARK_BOOKMARK - 1 - local line = f(buffer, current_line + (next and 1 or -1), BOOKMARK_BIT) + line = f(buffer, line + (next and 1 or -1), BOOKMARK_BIT) if line == -1 then line = f(buffer, (next and 1 or buffer.line_count), BOOKMARK_BIT) end if line >= 1 then textadept.editing.goto_line(line) end return end - local scan_this_buffer, utf8_list, buffers = true, {}, {} -- List the current buffer's marks, and then all other buffers' marks. + local scan_this_buffer, utf8_list, buffers = true, {}, {} ::rescan:: for _, buffer in ipairs(_BUFFERS) do if not (scan_this_buffer == (buffer == _G.buffer)) then goto continue end -- cgit v1.2.3