aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2016-01-29 18:08:11 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2016-01-29 18:08:11 -0500
commit78ea692c5a7a233716e02c5897048560353793aa (patch)
tree277fe7cf7ee1984916b1d8199fa88c561f870240
parent0ce6dc459507ad755d006a2050b6566cb6f429ca (diff)
downloadtextadept-78ea692c5a7a233716e02c5897048560353793aa.tar.gz
textadept-78ea692c5a7a233716e02c5897048560353793aa.zip
Fixed focus bug in `view:goto_buffer()` with non-focused view; src/textadept.c
-rw-r--r--src/textadept.c9
1 files changed, 4 insertions, 5 deletions
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;
}