summaryrefslogtreecommitdiff
path: root/src/options.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-01-12 10:23:43 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-01-12 10:23:43 +0900
commit5460517bd2ecf5c3437cfe77821b3cf524bc69d5 (patch)
tree848a6096a0fd1b8d41771dea150e824ff9f1adf3 /src/options.go
parent9a6e557e5237a6f5476cd602fc6425d3f05700b3 (diff)
downloadfzf-5460517bd2ecf5c3437cfe77821b3cf524bc69d5.tar.gz
Treat a single-character delimiter as a plain string delimiter
even if it's a regular expression meta-character Close #4170
Diffstat (limited to 'src/options.go')
-rw-r--r--src/options.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/options.go b/src/options.go
index 404958c7..ac4a1aca 100644
--- a/src/options.go
+++ b/src/options.go
@@ -755,18 +755,23 @@ func delimiterRegexp(str string) Delimiter {
// Special handling of \t
str = strings.ReplaceAll(str, "\\t", "\t")
- // 1. Pattern does not contain any special character
+ // 1. Pattern is a single character
+ if len([]rune(str)) == 1 {
+ return Delimiter{str: &str}
+ }
+
+ // 2. Pattern does not contain any special character
if regexp.QuoteMeta(str) == str {
return Delimiter{str: &str}
}
rx, e := regexp.Compile(str)
- // 2. Pattern is not a valid regular expression
+ // 3. Pattern is not a valid regular expression
if e != nil {
return Delimiter{str: &str}
}
- // 3. Pattern as regular expression. Slow.
+ // 4. Pattern as regular expression. Slow.
return Delimiter{regex: rx}
}