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

Commit

Permalink
Merge pull request #60 from atom/aw/newlines
Browse files Browse the repository at this point in the history
Always treat \r and \n as newlines
  • Loading branch information
smashwilson authored Mar 27, 2018
2 parents 2f61b50 + d95847c commit e367184
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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

0 comments on commit e367184

Please # to comment.