handle regexps with missing \E (quick fix for #3700)

This commit is contained in:
matthias314
2025-11-18 10:47:49 -05:00
parent 9183fbe640
commit a577fc95ff

View File

@@ -41,12 +41,21 @@ func findLineParams(b *Buffer, start, end Loc, i int, r *regexp.Regexp) ([]byte,
} }
} }
if padMode == padStart { if padMode != 0 {
r = regexp.MustCompile(".(?:" + r.String() + ")") re, err := regexp.Compile(r.String() + `\E`)
} else if padMode == padEnd { if err == nil {
r = regexp.MustCompile("(?:" + r.String() + ").") // r contains \Q without closing \E
} else if padMode == padStart|padEnd { r = re
r = regexp.MustCompile(".(?:" + r.String() + ").") }
if padMode == padStart {
r = regexp.MustCompile(".(?:" + r.String() + ")")
} else if padMode == padEnd {
r = regexp.MustCompile("(?:" + r.String() + ").")
} else {
// padMode == padStart|padEnd
r = regexp.MustCompile(".(?:" + r.String() + ").")
}
} }
return l, charpos, padMode, r return l, charpos, padMode, r