- for _, v in ipairs(t) do
- if v.kcb then
- v.kcb=string.gsub(v.kcb, "AnyModifier%+", "")
- end
- if v.action=="doc" then
- outi=outi+1
- out[outi]={doc=v.text, bindings={}}
- elseif v.submap then
- parsetable(v.submap, prefix..v.kcb.." ")
- else
- assert(out[outi])
- v.kcb=prefix..v.kcb
- table.insert(out[outi].bindings, v)
+ --for _, v in ipairs(t) do
+ -- ipairs doesn't like nil values, that e.g. submap_wait dummy might generate
+ for i=1,#t do
+ local v=t[i]
+ if v and not v.invalid then
+ if v.kcb then
+ v.kcb=string.gsub(v.kcb, "AnyModifier%+", "")
+ end
+ if v.action=="doc" then
+ if outi==0 or #out[outi].bindings>0 then
+ outi=outi+1
+ end
+ out[outi]={doc=v.text, bindings={}}
+ elseif v.submap then
+ parsetable(v.submap, prefix..v.kcb.." ")
+ else
+ assert(out[outi])
+ v.kcb=prefix..v.kcb
+ table.insert(out[outi].bindings, v)
+ end