We treat false as empty table if the default value is table

This commit is contained in:
hrsh7th
2021-08-29 21:33:45 +09:00
parent b29356a176
commit 684d862526
2 changed files with 7 additions and 2 deletions

View File

@@ -38,6 +38,11 @@ misc.merge = function(v1, v2)
if v1 == nil then
return v2
end
-- treat false as {} if the default value is table.
if merge2 and v1 == false then
return {}
end
return v1
end

View File

@@ -22,8 +22,8 @@ describe('misc', function()
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)