Fix delimiter regex to properly support caret (^)

Fix #2861
This commit is contained in:
Junegunn Choi committed 2022-07-21 21:21:06 +09:00
1 parent ccc4677252
commit 0d06c28b19
2 files changed
+21 -8

No files matched your search

+13
View File
@@ -65,6 +65,19 @@ func TestDelimiterRegexRegex(t *testing.T) {
}
}
func TestDelimiterRegexRegexCaret(t *testing.T) {
delim := delimiterRegexp(`(^\s*|\s+)`)
tokens := Tokenize("foo bar baz", delim)
if delim.str != nil ||
len(tokens) != 4 ||
tokens[0].text.ToString() != "" ||
tokens[1].text.ToString() != "foo " ||
tokens[2].text.ToString() != "bar " ||
tokens[3].text.ToString() != "baz" {
t.Errorf("%s %d", tokens, len(tokens))
}
}
func TestSplitNth(t *testing.T) {
{
ranges := splitNth("..")