hints kitten: Fix a regression in 0.28.0 that broke using sub-groups in regexp captures
Fixes #6228
This commit is contained in:
parent
f6ccd2ad2c
commit
1fc4e53bea
@ -48,6 +48,8 @@ Detailed list of changes
|
|||||||
|
|
||||||
- show_key kitten: In kitty mode show the actual bytes sent by the terminal rather than a re-encoding of the parsed key event
|
- show_key kitten: In kitty mode show the actual bytes sent by the terminal rather than a re-encoding of the parsed key event
|
||||||
|
|
||||||
|
- hints kitten: Fix a regression in 0.28.0 that broke using sub-groups in regexp captures (:iss:`6228`)
|
||||||
|
|
||||||
0.28.1 [2023-04-21]
|
0.28.1 [2023-04-21]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@ -314,6 +314,12 @@ func mark(r *regexp.Regexp, post_processors []PostProcessorFunc, group_processor
|
|||||||
for k, v := range gd {
|
for k, v := range gd {
|
||||||
gd2[k] = v
|
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{
|
ans = append(ans, Mark{
|
||||||
Index: i, Start: match_start, End: match_end, Text: full_match, Groupdict: gd2,
|
Index: i, Start: match_start, End: match_end, Text: full_match, Groupdict: gd2,
|
||||||
})
|
})
|
||||||
|
|||||||
@ -47,7 +47,7 @@ func TestHintMarking(t *testing.T) {
|
|||||||
for _, m := range marks {
|
for _, m := range marks {
|
||||||
q := strings.NewReplacer("\n", "", "\r", "", "\x00", "").Replace(ptext[m.Start:m.End])
|
q := strings.NewReplacer("\n", "", "\r", "", "\x00", "").Replace(ptext[m.Start:m.End])
|
||||||
if diff := cmp.Diff(m.Text, q); diff != "" {
|
if diff := cmp.Diff(m.Text, q); diff != "" {
|
||||||
t.Fatalf("Mark start and end dont point to correct offset in text for %#v\n%s", text, diff)
|
t.Fatalf("Mark start (%d) and end (%d) dont point to correct offset in text for %#v\n%s", m.Start, m.End, text, diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -107,6 +107,11 @@ func TestHintMarking(t *testing.T) {
|
|||||||
r(`255.255.255.256`)
|
r(`255.255.255.256`)
|
||||||
r(`:1`)
|
r(`:1`)
|
||||||
|
|
||||||
|
reset()
|
||||||
|
opts.Type = "regex"
|
||||||
|
opts.Regex = `(?ms)^[*]?\s(\S+)`
|
||||||
|
r(`* 2b687c2 - test1`, `2b687c2`)
|
||||||
|
|
||||||
reset()
|
reset()
|
||||||
tdir := t.TempDir()
|
tdir := t.TempDir()
|
||||||
simple := filepath.Join(tdir, "simple.py")
|
simple := filepath.Join(tdir, "simple.py")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user