hints kitten: Fix a regression in 0.28.0 that broke using sub-groups in regexp captures

Fixes #6228
This commit is contained in:
Kovid Goyal
2023-04-30 21:16:24 +05:30
parent f6ccd2ad2c
commit 1fc4e53bea
3 changed files with 14 additions and 1 deletions

View File

@@ -314,6 +314,12 @@ func mark(r *regexp.Regexp, post_processors []PostProcessorFunc, group_processor
for k, v := range gd {
gd2[k] = v
}
if opts.Type == "regex" && len(names) > 1 && names[1] == "" {
ms, me := v[2], v[3]
match_start = utils.Max(match_start, ms)
match_end = utils.Min(match_end, me)
full_match = sanitize_pat.ReplaceAllLiteralString(text[match_start:match_end], "")
}
ans = append(ans, Mark{
Index: i, Start: match_start, End: match_end, Text: full_match, Groupdict: gd2,
})