diff --git a/src/base/context.lua b/src/base/context.lua index 0e1c662e32..fe0e80f1f8 100644 --- a/src/base/context.lua +++ b/src/base/context.lua @@ -137,8 +137,12 @@ -- function context.mergeFilters(ctx, src) - for k,v in pairs(src.terms) do - ctx.terms[k] = v + for k, v in pairs(src.terms) do + if k == "tags" then + ctx.terms[k] = table.join(ctx.terms[k], v) + else + ctx.terms[k] = v + end end end diff --git a/tests/base/test_context.lua b/tests/base/test_context.lua index f04ee7ba6e..6e98ed42a0 100644 --- a/tests/base/test_context.lua +++ b/tests/base/test_context.lua @@ -73,3 +73,41 @@ -- detoken in extended context should result in value set in that environ. test.isequal("text", ext.targetname) end + +-- +-- mergeFilters should behave as expected for tags +-- + + function suite.mergeFilters() + + ctx = { terms = { tags = { "ctxtags" } } } + src = { terms = { tags = { "srctags" } } } + + context.mergeFilters(ctx, src) + + result = { terms = { tags = { "ctxtags", "srctags" } } } + + test.isequal(result, ctx) + end + + function suite.mergeFilters_keeptype() + + ctx = { terms = { kind = "ConsoleApp" } } + src = { terms = { kind = "ConsoleApp" } } + + context.mergeFilters(ctx, src) + + test.isequal("string", type(ctx.terms.kind)) + end + + function suite.mergeFilters_createtable() + + ctx = { terms = { tags = "ctxtags" } } + src = { terms = { tags = "srctags" } } + + context.mergeFilters(ctx, src) + + result = { terms = { tags = { "ctxtags", "srctags" } } } + + test.isequal(result, ctx) + end