aboutsummaryrefslogtreecommitdiff
path: root/vis-lua.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-03-19 12:13:44 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-03-19 14:58:06 +0100
commit8919fd1cbeef89aa3a5fce9c00aa708335e1de85 (patch)
tree95c9201db0f439bac30cd6f9cc338cd73ada8fe9 /vis-lua.c
parent9a3d7e57784fdef3bd954ac78d25cb3e88f0a12b (diff)
downloadvis-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.
Diffstat (limited to 'vis-lua.c')
-rw-r--r--vis-lua.c6
1 files changed, 4 insertions, 2 deletions
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;
}