Merge #1981 'treat NULL initialized vimscript string as api type String'

This commit is contained in:
Justin M. Keyes
2015-02-16 20:13:55 -05:00
3 changed files with 8 additions and 5 deletions

View File

@@ -644,10 +644,8 @@ static Object vim_to_object_rec(typval_T *obj, PMap(ptr_t) *lookup)
switch (obj->v_type) { switch (obj->v_type) {
case VAR_STRING: case VAR_STRING:
if (obj->vval.v_string != NULL) { rv.type = kObjectTypeString;
rv.type = kObjectTypeString; rv.data.string = cstr_to_string((char *) obj->vval.v_string);
rv.data.string = cstr_to_string((char *) obj->vval.v_string);
}
break; break;
case VAR_NUMBER: case VAR_NUMBER:

View File

@@ -27,6 +27,11 @@ describe('vim_* functions', function()
nvim('command', 'let g:v2 = [1, 2, {"v3": 3}]') nvim('command', 'let g:v2 = [1, 2, {"v3": 3}]')
eq({v1 = 'a', v2 = {1, 2, {v3 = 3}}}, nvim('eval', 'g:')) eq({v1 = 'a', v2 = {1, 2, {v3 = 3}}}, nvim('eval', 'g:'))
end) end)
it('handles NULL-initialized strings correctly', function()
eq(1, nvim('eval',"matcharg(1) == ['', '']"))
eq({'', ''}, nvim('eval','matcharg(1)'))
end)
end) end)
describe('strwidth', function() describe('strwidth', function()

View File

@@ -191,7 +191,7 @@ describe('system()', function()
if xclip then if xclip then
describe("with a program that doesn't close stdout", function() describe("with a program that doesn't close stdout", function()
it('will exit properly after passing input', function() it('will exit properly after passing input', function()
eq(nil, eval([[system('xclip -i -selection clipboard', 'clip-data')]])) eq('', eval([[system('xclip -i -selection clipboard', 'clip-data')]]))
eq('clip-data', eval([[system('xclip -o -selection clipboard')]])) eq('clip-data', eval([[system('xclip -o -selection clipboard')]]))
end) end)
end) end)