File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -75,8 +75,15 @@ const { StringDecoder } = require('string_decoder');
75
75
const kHistorySize = 30 ;
76
76
const kMaxUndoRedoStackSize = 2048 ;
77
77
const kMincrlfDelay = 100 ;
78
- // \r\n, \n, or \r followed by something other than \n
79
- const lineEnding = / \r ? \n | \r (? ! \n ) / g;
78
+ /**
79
+ * The end of a line is signaled by either one of the following:
80
+ * - \r\n
81
+ * - \n
82
+ * - \r followed by something other than \n
83
+ * - \u2028 (Unicode 'LINE SEPARATOR')
84
+ * - \u2029 (Unicode 'PARAGRAPH SEPARATOR')
85
+ */
86
+ const lineEnding = / \r ? \n | \r (? ! \n ) | \u2028 | \u2029 / g;
80
87
81
88
const kLineObjectStream = Symbol ( 'line object stream' ) ;
82
89
const kQuestionCancel = Symbol ( 'kQuestionCancel' ) ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const common = require ( '../common' ) ;
3
+ const assert = require ( 'node:assert' ) ;
4
+ const readline = require ( 'node:readline' ) ;
5
+ const { Readable } = require ( 'node:stream' ) ;
6
+
7
+ const str = '123\n456\r789\u{2028}ABC\u{2029}DEF' ;
8
+
9
+ const rli = new readline . Interface ( {
10
+ input : Readable . from ( str ) ,
11
+ } ) ;
12
+
13
+ const linesRead = [ ] ;
14
+ rli . on ( 'line' , ( line ) => linesRead . push ( line ) ) ;
15
+
16
+ rli . on ( 'close' , common . mustCall ( ( ) => {
17
+ const regexpLines = str . split ( / ^ / m) . map ( ( line ) => line . trim ( ) ) ;
18
+ // Readline interprets different lines in the same way js regular expressions do
19
+ assert . deepStrictEqual ( linesRead , regexpLines ) ;
20
+ } ) ) ;
You can’t perform that action at this time.
0 commit comments