diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-03-19 12:13:44 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-03-19 14:58:06 +0100 |
| commit | 8919fd1cbeef89aa3a5fce9c00aa708335e1de85 (patch) | |
| tree | 95c9201db0f439bac30cd6f9cc338cd73ada8fe9 | |
| parent | 9a3d7e57784fdef3bd954ac78d25cb3e88f0a12b (diff) | |
| download | vis-8919fd1cbeef89aa3a5fce9c00aa708335e1de85.tar.gz vis-8919fd1cbeef89aa3a5fce9c00aa708335e1de85.tar.xz | |
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.
| -rw-r--r-- | vis-lua.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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; } |
