From b178dd7961297818664091047c89b05329f33dc9 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sat, 11 Aug 2007 03:07:34 -0400 Subject: Fixed bug in restoring scroll position on buffer switching; src/lua_interface.c When switching to another buffer, typing text, and switching back, the scroll position was not restored properly all of the time. Fixed by setting the anchor and caret first, which scrolls some number of lines, then scrolling the remaining number of lines to restore the original scroll position. --- src/lua_interface.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lua_interface.c b/src/lua_interface.c index 881a216a..c3f8d99d 100644 --- a/src/lua_interface.c +++ b/src/lua_interface.c @@ -264,13 +264,14 @@ void l_goto_scintilla_buffer(GtkWidget *editor, int n, bool absolute) { l_set_buffer_global(sci); // Restore this buffer's properties. lua_getglobal(lua, "buffer"); - l_get_buffer_prop("_first_visible_line", -2); - SS(sci, SCI_LINESCROLL, 0, - SS(sci, SCI_VISIBLEFROMDOCLINE, lua_tointeger(lua, -1))); - l_get_buffer_prop("_anchor", -3); - l_get_buffer_prop("_current_pos", -4); + l_get_buffer_prop("_anchor", -2); + l_get_buffer_prop("_current_pos", -3); SS(sci, SCI_SETSEL, lua_tointeger(lua, -2), lua_tointeger(lua, -1)); - lua_pop(lua, 4); // _first_visible_line, _anchor, _current_pos, and buffer + l_get_buffer_prop("_first_visible_line", -4); + SS(sci, SCI_LINESCROLL, 0, + SS(sci, SCI_VISIBLEFROMDOCLINE, lua_tointeger(lua, -1)) - + SS(sci, SCI_GETFIRSTVISIBLELINE)); + lua_pop(lua, 4); // _anchor, _current_pos, _first_visible_line, and buffer if (!closing) l_handle_signal("buffer_switch"); lua_pop(lua, 2); // buffer table and buffers } -- cgit v1.2.3