Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
patch 8.1.0164: luaeval('vim.buffer().name') returns an error
Problem:    luaeval('vim.buffer().name') returns an error.
Solution:   Return an empty string. (Dominique Pelle, closes #3167)
  • Loading branch information
brammool committed Jul 7, 2018
1 parent 2549acf commit fe08df4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/if_lua.c
Expand Up @@ -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 */
Expand Down
7 changes: 2 additions & 5 deletions src/testdir/test_lua.vim
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -789,6 +789,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
164,
/**/
163,
/**/
Expand Down

0 comments on commit fe08df4

Please sign in to comment.