We treat false as empty table if the default value is table
This commit is contained in:
@@ -38,6 +38,11 @@ misc.merge = function(v1, v2)
|
|||||||
if v1 == nil then
|
if v1 == nil then
|
||||||
return v2
|
return v2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- treat false as {} if the default value is table.
|
||||||
|
if merge2 and v1 == false then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
return v1
|
return v1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ describe('misc', function()
|
|||||||
b = 1
|
b = 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
assert.are.equal(merged.a, false)
|
assert.are.equal(type(merged.a), 'table')
|
||||||
|
assert.are.equal(vim.tbl_isempty(merged.a), true)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user