Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Always treat \r and \n as newlines #60

Merged
merged 3 commits into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/core/regex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ Regex::Regex(const char16_t *pattern, uint32_t pattern_length, u16string *error_

u16string final_pattern = preprocess_pattern(pattern, pattern_length);

pcre2_compile_context *context = pcre2_compile_context_create(nullptr);
pcre2_set_newline(context, PCRE2_NEWLINE_ANY);

int error_number = 0;
size_t error_offset = 0;
uint32_t options = PCRE2_MULTILINE;
Expand All @@ -58,8 +61,9 @@ Regex::Regex(const char16_t *pattern, uint32_t pattern_length, u16string *error_
options,
&error_number,
&error_offset,
nullptr
context
);
pcre2_compile_context_free(context);

if (!code) {
uint16_t message_buffer[256];
Expand Down
5 changes: 5 additions & 0 deletions test/js/text-buffer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,11 @@ describe('TextBuffer', () => {
Range(Point(5, 0), Point(5, 0))
])
})

it('does not match \\r with .', () => {
const buffer = new TextBuffer('\r')
assert.lengthOf(buffer.findAllInRangeSync(/./, Range(Point(0, 0), Point(Infinity, Infinity))), 0)
})
})

describe('.findAndMarkAllSync', () => {
Expand Down