From 78ea692c5a7a233716e02c5897048560353793aa Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Fri, 29 Jan 2016 18:08:11 -0500 Subject: Fixed focus bug in `view:goto_buffer()` with non-focused view; src/textadept.c --- src/textadept.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/textadept.c b/src/textadept.c index 867b872d..466a8413 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -1958,14 +1958,13 @@ static Scintilla *lL_checkview(lua_State *L, int arg) { static int lview_goto_buffer(lua_State *L) { Scintilla *view = lL_checkview(L, 1), *prev_view = focused_view; int n = luaL_checkinteger(L, 2), relative = lua_toboolean(L, 3); - // If the indexed view is not currently focused, temporarily focus it so calls - // to handlers will not throw 'indexed buffer is not the focused one' error. - int switch_focus = (view != focused_view); - if (switch_focus) SS(view, SCI_SETFOCUS, TRUE, 0); + // If the indexed view is not currently focused, temporarily focus it so + // `_G.buffer` in handlers is accurate. + if (view != focused_view) focus_view(view); if (!initing) lL_event(L, "buffer_before_switch", -1); lL_gotodoc(L, view, n, relative); if (!initing) lL_event(L, "buffer_after_switch", -1); - if (switch_focus) SS(view, SCI_SETFOCUS, FALSE, 0), focus_view(prev_view); + if (focused_view != prev_view) focus_view(prev_view); return 0; } -- cgit v1.2.3