hints kitten: Switch to using a regex engine that supports lookaround

Note that we loose unicode char matching for --type=word because of
https://github.com/dlclark/regexp2/issues/65 and of course user regexps
cant use \p{N} escapes any more. Hopefully regexp2 will add support for
these soon-ish. IMO lookaround is more important than \p.

Fixes #6265
This commit is contained in:
Kovid Goyal
2023-05-12 12:24:59 +05:30
parent 5b8b91b6a3
commit 65f8bb7397
4 changed files with 135 additions and 19 deletions

View File

@@ -111,6 +111,14 @@ func TestHintMarking(t *testing.T) {
opts.Type = "regex"
opts.Regex = `(?ms)^[*]?\s(\S+)`
r(`* 2b687c2 - test1`, `2b687c2`)
opts.Regex = `(?<=got: )sha256.{4}`
r(`got: sha256-L8=`, `sha256-L8=`)
reset()
opts.Type = "word"
r(`#one (two) 😍 a-1b `, `#one`, `two`, `a-1b`)
// non-ascii words dont match because of https://github.com/dlclark/regexp2/issues/65
// r(`fōtiz час`, `fōtiz`, `час`)
reset()
tdir := t.TempDir()