cursive icon indicating copy to clipboard operation
cursive copied to clipboard

Long strings in REPL output interpret \\n as line breaks

Open chrisbroome opened this issue 2 years ago • 0 comments

Issue

Long string values that contain a backslash \\ followed by the letter n will incorrectly output in the REPL with line breaks.

Repro

  1. Navigate to Preferences, Languages & Frameworks, Clojure.
    • Note your Preferences, Editor, Code Style, Hard wrap at X columns setting. For this example, we'll say that it's set to 120 characters
  2. On the right-hand side make sure "Pretty print REPL return values" and "Split and align multi-line strings" are both checked.
  3. Evaluate a long text string literal (must be longer than the editor's "Hard wrap" at X columns setting) that has a backslash \\ character followed by the letter n:
"C:\\some-really-long-path\\that-would-make-the-string-wrap\\and-is-followed-by-a-part-that-starts-with-the-letter-n\\new.txt"

Expected Output

"C:\\some-really-long-path\\that-would-make-the-string-wrap\\and-is-followed-by-a-part-that-starts-with-the-letter-n\\new.txt"

Actual Output

"C:\\some-really-long-path\\that-would-make-the-string-wrap\\and-is-followed-by-a-part-that-starts-with-the-letter-n\
 ew.txt"

Notes

It's subtle, but "\\n" gets converted to a backslash and newline instead of a backslash and the n character.

chrisbroome avatar Jun 01 '22 12:06 chrisbroome