summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-07-07 23:07:41 +0200
committerBram Moolenaar <Bram@vim.org>2018-07-07 23:07:41 +0200
commitfe08df452af10db8a24dbeb1bd9ef09492a4bc66 (patch)
tree6efc248890dc4e3d4096d52d9b6eb99721e21787
parent2549acf794109731eab693bd396bb863d0e2cff4 (diff)
downloadvim-git-fe08df452af10db8a24dbeb1bd9ef09492a4bc66.tar.gz
patch 8.1.0164: luaeval('vim.buffer().name') returns an errorv8.1.0164
Problem: luaeval('vim.buffer().name') returns an error. Solution: Return an empty string. (Dominique Pelle, closes #3167)
-rw-r--r--src/if_lua.c6
-rw-r--r--src/testdir/test_lua.vim7
-rw-r--r--src/version.c2
3 files changed, 8 insertions, 7 deletions
diff --git a/src/if_lua.c b/src/if_lua.c
index df0ef3454..f0d5a4d04 100644
--- a/src/if_lua.c
+++ b/src/if_lua.c
@@ -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 */
diff --git a/src/testdir/test_lua.vim b/src/testdir/test_lua.vim
index 73134718d..228079203 100644
--- a/src/testdir/test_lua.vim
+++ b/src/testdir/test_lua.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 0215c9d14..4338a64d6 100644
--- a/src/version.c
+++ b/src/version.c
@@ -790,6 +790,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 164,
+/**/
163,
/**/
162,