From dc40bb96bc2d734075a7b797814de431eff6edcc Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 16 Jun 2017 09:56:07 -0700 Subject: [PATCH] Configure PCRE to treat CRLF as a line ending --- test/native/text-buffer-test.cc | 9 +++++++++ vendor/pcre/include/config.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/test/native/text-buffer-test.cc b/test/native/text-buffer-test.cc index 06058b33..c7aa379d 100644 --- a/test/native/text-buffer-test.cc +++ b/test/native/text-buffer-test.cc @@ -372,6 +372,15 @@ TEST_CASE("TextBuffer::find_all") { })); } +TEST_CASE("TextBuffer::find_all - CRLF line endings") { + TextBuffer buffer{u"abc\ndef\r\nghi"}; + REQUIRE(buffer.find_all(Regex(u"\\w$", nullptr)) == vector({ + Range{Point{0, 2}, Point{0, 3}}, + Range{Point{1, 2}, Point{1, 3}}, + Range{Point{2, 2}, Point{2, 3}}, + })); +} + struct SnapshotData { Text base_text; String text; diff --git a/vendor/pcre/include/config.h b/vendor/pcre/include/config.h index 3315b777..bdcd2178 100644 --- a/vendor/pcre/include/config.h +++ b/vendor/pcre/include/config.h @@ -199,7 +199,7 @@ sure both macros are undefined; an emulation function will then be used. */ at run time. The valid values are 1 (CR), 2 (LF), 3 (CRLF), 4 (ANY), and 5 (ANYCRLF). */ #ifndef NEWLINE_DEFAULT -#define NEWLINE_DEFAULT 2 +#define NEWLINE_DEFAULT 4 #endif /* Name of package */