From d936651cc68a785b88281c9047b220fc28605168 Mon Sep 17 00:00:00 2001 From: Scarab Systems Date: Sun, 7 Jun 2026 20:23:26 -0400 Subject: [PATCH] readline: add unicode line separator option Signed-off-by: Scarab Systems --- doc/api/readline.md | 17 ++++++- lib/internal/readline/interface.js | 14 ++++++ lib/readline.js | 1 + .../parallel/test-readline-line-separators.js | 48 +++++++++++++++---- 4 files changed, 70 insertions(+), 10 deletions(-) diff --git a/doc/api/readline.md b/doc/api/readline.md index 02e56e4c6a322b..5c3832d37c5309 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -120,8 +120,10 @@ added: v0.1.98 --> The `'line'` event is emitted whenever the `input` stream receives an -end-of-line input (`\n`, `\r`, or `\r\n`). This usually occurs when the user -presses Enter or Return. +end-of-line input (`\n`, `\r`, or `\r\n`). By default, Unicode line separator +(`\u2028`) and paragraph separator (`\u2029`) characters are also treated as +end-of-line input. This usually occurs when the user presses Enter +or Return. The `'line'` event is also emitted if new data has been read from a stream and that stream ends without a final end-of-line marker. @@ -525,6 +527,10 @@ changes: * Extends: {readline.InterfaceConstructor} @@ -716,6 +722,8 @@ added: v17.0.0 `100`. It can be set to `Infinity`, in which case `\r` followed by `\n` will always be considered a single newline (which may be reasonable for [reading files][] with `\r\n` line delimiter). **Default:** `100`. + * `unicodeLineSeparators` {boolean} If `true`, `\u2028` and `\u2029` will be + treated as end-of-line input. **Default:** `true`. * `escapeCodeTimeout` {number} The duration `readlinePromises` will wait for a character (when reading an ambiguous key sequence in milliseconds one that can both form a complete key sequence using the input read so far and can @@ -924,6 +932,9 @@ the current position of the cursor down.