From 2247caa255f3a9cdf3413e5396d814fe4a092506 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Thu, 26 Feb 2009 19:54:17 -0500 Subject: Update the PM cursor on menu action; core/ext/pm/buffer_browser.lua --- core/ext/pm/buffer_browser.lua | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/core/ext/pm/buffer_browser.lua b/core/ext/pm/buffer_browser.lua index 61f8b26e..4f618368 100644 --- a/core/ext/pm/buffer_browser.lua +++ b/core/ext/pm/buffer_browser.lua @@ -49,6 +49,18 @@ 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() @@ -64,20 +76,9 @@ function perform_menu_action(menu_id, selected_item) view:goto_buffer(tonumber(selected_item[2])) buffer:close() end - textadept.pm.activate() + update_view() 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 textadept.events.add_handler('file_opened', update_view) textadept.events.add_handler('buffer_new', update_view) textadept.events.add_handler('buffer_deleted', update_view) @@ -85,4 +86,3 @@ 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) - -- cgit v1.2.3