Boop icon indicating copy to clipboard operation
Boop copied to clipboard

Fix join line scripts not handling Windows CRLF line endings

Open tathagat22 opened this issue 7 months ago • 1 comments

What

Fixes #128 — all three Join Lines scripts (JoinLines, JoinLinesWithSpace, JoinLinesWithComma) only worked correctly with Unix line endings (\n). Text pasted from Windows apps uses \r\n, which caused the scripts to leave \r characters behind, resulting in broken/partial output.

Why

The original regex /\n/g matches only Unix newlines. Windows line endings are \r\n, so after removing \n, a stray \r (carriage return) remained in the output. This made the joined text appear incorrectly in the editor.

Fix

Changed all three scripts from:

input.text = input.text.replace(/\n/g, '...');

to:

input.text = input.text.replace(/\r\n|\r|\n/g, '...');

This handles all three common line ending styles:

  • Unix: \n
  • Windows: \r\n
  • Legacy Mac: \r

Testing

Verified with Node.js that 4-line text with \r\n endings is now fully joined across all scripts.

tathagat22 avatar May 04 '26 20:05 tathagat22