From 98d193eaad207c87416f364592693872c98ddc78 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sun, 8 Mar 2009 16:29:43 -0400 Subject: Fixed issue with buffer browser cursor saving; core/ext/pm/buffer_browser.lua --- core/ext/pm/buffer_browser.lua | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'core/ext') diff --git a/core/ext/pm/buffer_browser.lua b/core/ext/pm/buffer_browser.lua index 4f618368..d1fa4295 100644 --- a/core/ext/pm/buffer_browser.lua +++ b/core/ext/pm/buffer_browser.lua @@ -49,18 +49,6 @@ function get_context_menu(selected_item) } end -local function update_view() - if matches(textadept.pm.entry_text) then - textadept.pm.activate() - for idx, buf in ipairs(textadept.buffers) do - if buf == buffer then - textadept.pm.cursor = idx - 1 - break - end - end - end -end - function perform_menu_action(menu_id, selected_item) if menu_id == ID.NEW then textadept.new_buffer() @@ -76,9 +64,12 @@ function perform_menu_action(menu_id, selected_item) view:goto_buffer(tonumber(selected_item[2])) buffer:close() end - update_view() + textadept.pm.activate() end +local function update_view() + if matches(textadept.pm.entry_text) then textadept.pm.activate() end +end textadept.events.add_handler('file_opened', update_view) textadept.events.add_handler('buffer_new', update_view) textadept.events.add_handler('buffer_deleted', update_view) @@ -86,3 +77,15 @@ textadept.events.add_handler('save_point_reached', update_view) textadept.events.add_handler('save_point_left', update_view) textadept.events.add_handler('buffer_switch', update_view) textadept.events.add_handler('view_switch', update_view) + +local function set_cursor() + if matches(textadept.pm.entry_text) then + for idx, buf in ipairs(textadept.buffers) do + if buf == buffer then + textadept.pm.cursor = idx - 1 + break + end + end + end +end +textadept.events.add_handler('pm_view_filled', set_cursor) -- cgit v1.2.3