diff --git a/data/core/syntax.lua b/data/core/syntax.lua index 89208bc..977983c 100644 --- a/data/core/syntax.lua +++ b/data/core/syntax.lua @@ -30,12 +30,17 @@ end local function find(string, field) + local best_match = 0 + local best_syntax for i = #syntax.items, 1, -1 do local t = syntax.items[i] - if common.match_pattern(string, t[field] or {}) then - return t + local s, e = common.match_pattern(string, t[field] or {}) + if s and e - s > best_match then + best_match = e - s + best_syntax = t end end + return best_syntax end function syntax.get(filename, header)