]> granicus.if.org Git - vim/commitdiff
patch 8.1.0164: luaeval('vim.buffer().name') returns an error v8.1.0164
authorBram Moolenaar <Bram@vim.org>
Sat, 7 Jul 2018 21:07:41 +0000 (23:07 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 7 Jul 2018 21:07:41 +0000 (23:07 +0200)
Problem:    luaeval('vim.buffer().name') returns an error.
Solution:   Return an empty string. (Dominique Pelle, closes #3167)

src/if_lua.c
src/testdir/test_lua.vim
src/version.c

index df0ef345459ca1fdf8f05b0fb7d70403d436bb3c..f0d5a4d04d7cbd8107af2339e37b8c3ec873570e 100644 (file)
@@ -1123,9 +1123,11 @@ luaV_buffer_index(lua_State *L)
     {
        const char *s = lua_tostring(L, 2);
        if (strncmp(s, "name", 4) == 0)
-           lua_pushstring(L, (char *) b->b_sfname);
+           lua_pushstring(L, (b->b_sfname == NULL)
+                                       ? "" : (char *) b->b_sfname);
        else if (strncmp(s, "fname", 5) == 0)
-           lua_pushstring(L, (char *) b->b_ffname);
+           lua_pushstring(L, (b->b_ffname == NULL)
+                                       ? "" : (char *) b->b_ffname);
        else if (strncmp(s, "number", 6) == 0)
            lua_pushinteger(L, b->b_fnum);
        /* methods */
index 73134718d327ec5456fe5dc5e0910872be80b33a..22807920346be775ba49ca4c8e26f127a8323eec 100644 (file)
@@ -198,11 +198,8 @@ endfunc
 " Test vim.buffer().name and vim.buffer().fname
 func Test_buffer_name()
   new
-  " FIXME: for an unnamed buffer, I would expect
-  " vim.buffer().name to give an empty string, but
-  " it returns 0. Is it a bug?
-  " so this assert_equal is commented out.
-  " call assert_equal('', luaeval('vim.buffer().name'))
+  call assert_equal('', luaeval('vim.buffer().name'))
+  call assert_equal('', luaeval('vim.buffer().fname'))
   bwipe!
 
   new Xfoo
index 0215c9d1434741e2d31527b65dc0771124775b96..4338a64d6d452d078ccd363da9cd6046d995ac56 100644 (file)
@@ -789,6 +789,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    164,
 /**/
     163,
 /**/