Treat a single-character delimiter as a plain string delimiter

even if it's a regular expression meta-character

Close #4170
This commit is contained in:
Junegunn Choi
2025-01-12 10:23:43 +09:00
parent 9a6e557e52
commit 5460517bd2
3 changed files with 18 additions and 5 deletions

View File

@@ -9,9 +9,13 @@ import (
)
func TestDelimiterRegex(t *testing.T) {
// Valid regex
// Valid regex, but a single character -> string
delim := delimiterRegexp(".")
if delim.regex == nil || delim.str != nil {
if delim.regex != nil || *delim.str != "." {
t.Error(delim)
}
delim = delimiterRegexp("|")
if delim.regex != nil || *delim.str != "|" {
t.Error(delim)
}
// Broken regex -> string