Skip to content

Commit

Permalink
vis-lua: do not report errors recursively
Browse files Browse the repository at this point in the history
Displaying an error might create a new window which in turn can
trigger new events (all other windows are resized+redrawn) which
might again cause errors.

There is still no sane way to exit the editor in this case, but
at least the error messages should be readable.
  • Loading branch information
martanne committed May 22, 2016
1 parent 6a7f125 commit 5c2ba12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions vis-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ struct Vis {
Buffer input_queue; /* holds pending input keys */
Buffer *keys; /* currently active keys buffer (either the input_queue or a macro) */
bool keyhandler; /* whether a key handling function is currently being called */
bool errorhandler; /* whether we are currently in an error handler, used to avoid recursion */
Action action; /* current action which is in progress */
Action action_prev; /* last operator action used by the repeat (dot) command */
Mode *mode; /* currently active mode, used to search for keybindings */
Expand Down
4 changes: 4 additions & 0 deletions vis-lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,16 @@ static void stack_dump(lua_State *L, const char *format, ...) {

static int error_function(lua_State *L) {
Vis *vis = lua_touserdata(L, lua_upvalueindex(1));
if (vis->errorhandler)
return 1;
vis->errorhandler = true;
size_t len;
const char *msg = lua_tostring(L, 1);
if (msg)
luaL_traceback(L, L, msg, 1);
msg = lua_tolstring(L, 1, &len);
vis_message_show(vis, msg);
vis->errorhandler = false;
return 1;
}

Expand Down

0 comments on commit 5c2ba12

Please sign in to comment.