aboutsummaryrefslogtreecommitdiff
path: root/src/lua_interface.c
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2007-08-11 03:07:34 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2007-08-11 03:07:34 -0400
commitb178dd7961297818664091047c89b05329f33dc9 (patch)
treee9fd55b844f2de235438e5529cae895e2d5b70b8 /src/lua_interface.c
parent00983a6a8b9d6e24a2d6f6f0807297314dee0423 (diff)
downloadtextadept-b178dd7961297818664091047c89b05329f33dc9.tar.gz
textadept-b178dd7961297818664091047c89b05329f33dc9.zip
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.
Diffstat (limited to 'src/lua_interface.c')
-rw-r--r--src/lua_interface.c13
1 files changed, 7 insertions, 6 deletions
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
}