diff options
| author | ruki <[email protected]> | 2017-01-12 23:17:50 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-01-12 23:17:50 +0800 |
| commit | c7629787087e6428e42884f57762f30a5d3ae683 (patch) | |
| tree | 0acaa9b5a6f9c90b7cf94fb26929060e4c545839 /xmake/core/language/menu.lua | |
| parent | a44dac295dc3fe982616bd642f0d3e36d3d1f2ec (diff) | |
fix menu options newlines
Diffstat (limited to 'xmake/core/language/menu.lua')
| -rw-r--r-- | xmake/core/language/menu.lua | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/xmake/core/language/menu.lua b/xmake/core/language/menu.lua index 965d7b101..f508df0bc 100644 --- a/xmake/core/language/menu.lua +++ b/xmake/core/language/menu.lua @@ -47,6 +47,7 @@ function menu.options(action) -- load and merge all language options local exist = {} local results = {} + local newline = false for _, instance in pairs(languages) do -- get menu @@ -57,38 +58,31 @@ function menu.options(action) local options = menu[action] if options then - -- exists options? - local exists = false + -- get the language option for _, option in ipairs(options) do - local name = option[2] - if name and not exist[name] then - exists = true - break - end - end - - -- merge it and remove repeat if exists options - if exists then - -- get the language option - for _, option in ipairs(options) do - - -- merge it and remove repeat - local name = option[2] - if name then - if not exist[name] then - table.insert(results, option) - exist[name] = true - end - else + -- merge it and remove repeat + local name = option[2] + if name then + if not exist[name] then table.insert(results, option) + exist[name] = true + newline = false end + elseif not newline then + table.insert(results, option) + newline = true end end end end end + -- remove the last empty option + if results[#results][2] == nil then + table.remove(results) + end + -- ok? return results end |
