about summary refs log tree commit diff stats
path: root/src/lua.c
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-11-11 17:41:37 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-11-11 17:41:37 -0800
commitd72eae59784e8da00c7fe00539b1095e1f8ccaf4 (patch)
tree417e71a4177143fef8e5f5becb0e4484213c6acd /src/lua.c
parente7f33de81e9528bdf8e3700ebd3cf7e8d776f2c6 (diff)
downloadteliva-d72eae59784e8da00c7fe00539b1095e1f8ccaf4.tar.gz
create empty file when navigating to empty definition
Diffstat (limited to 'src/lua.c')
-rw-r--r--src/lua.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lua.c b/src/lua.c
index 9b7cd76..08c5f92 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -323,9 +323,9 @@ void write_definition_to_file (lua_State *L, char *name, char *outfilename) {
     lua_getfield(L, -1, name);
     const char *contents = lua_tostring(L, -1);
     lua_pop(L, 1);
-    if (contents == NULL) return;
     int outfd = open(outfilename, O_WRONLY|O_CREAT|O_TRUNC, 0644);
-    write(outfd, contents, strlen(contents));
+    if (contents != NULL)
+      write(outfd, contents, strlen(contents));
     close(outfd);
 }
 
@@ -372,7 +372,7 @@ void switch_to_editor (lua_State *L, const char *message) {
   else {
     Current_definition = "main";
     write_definition_to_file(L, Current_definition, "teliva_editbuffer");
-    edit(L, "teliva_editbuffer", "");
+    edit(L, "teliva_editbuffer", /*status message*/ "");
     char new_contents[8192] = {0};
     read_contents(L, "teliva_editbuffer", new_contents);
     update_definition(L, Current_definition, new_contents);