about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/lua.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lua.c b/src/lua.c
index 95532f8..9a57e52 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -639,8 +639,14 @@ void recent_changes (lua_State *L) {
   assert(history_array == 1);
   int history_array_size = luaL_getn(L, history_array);
   int cursor = history_array_size;
+  lua_pop(L, 1);
   int quit = 0;
   while (!quit) {
+    /* refresh state after each operation so we pick up modifications */
+    lua_getglobal(L, "teliva_program");
+    int history_array = lua_gettop(L);
+    assert(history_array == 1);
+    int history_array_size = luaL_getn(L, history_array);
     render_recent_changes(L, history_array, cursor, history_array_size);
     int c = getch();
     switch (c) {
@@ -658,8 +664,8 @@ void recent_changes (lua_State *L) {
           add_undo_event(L, cursor);
         break;
     }
+    lua_pop(L, 1);
   }
-  lua_pop(L, 1);
 }