From 0d06c28b1943e820440cff9182a0ae3bdd5e3c59 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 21 Jul 2022 21:21:06 +0900 Subject: Fix delimiter regex to properly support caret (^) Fix #2861 --- src/options_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/options_test.go') diff --git a/src/options_test.go b/src/options_test.go index bb946235..b411e58e 100644 --- a/src/options_test.go +++ b/src/options_test.go @@ -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("..") -- cgit v1.2.3