From 8919fd1cbeef89aa3a5fce9c00aa708335e1de85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sun, 19 Mar 2017 12:13:44 +0100 Subject: vis-lua: make vis.win return nil if no window exists yet This is only the case during editor startup before the first window is created. --- vis-lua.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'vis-lua.c') diff --git a/vis-lua.c b/vis-lua.c index 0a3819f..4a3e1b0 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -1216,14 +1216,16 @@ static int pipe_func(lua_State *L) { * Whether a macro is being recorded. * @tfield bool recording */ -// TODO vis.ui static int vis_index(lua_State *L) { Vis *vis = obj_ref_check(L, 1, "vis"); if (lua_isstring(L, 2)) { const char *key = lua_tostring(L, 2); if (strcmp(key, "win") == 0) { - obj_ref_new(L, vis->win, VIS_LUA_TYPE_WINDOW); + if (vis->win) + obj_ref_new(L, vis->win, VIS_LUA_TYPE_WINDOW); + else + lua_pushnil(L); return 1; } -- cgit v1.2.3