Skip to content

rewrite-clj does not preserve CRLF whitespaces #187

Open
@ikappaki

Description

Version
1.1.45

Platform
Operating System: any
Clojure version: any
JDK vendor and version: any

Symptom
crewrite-clj does not preserve CRLF whitespace when converted from zipper back to string,

Reproduction
On the REPL:

(require '[rewrite-clj.zip :as z])
;; => nil
(-> (z/of-string "(ns nl-test\r\n  (:require [rewrite-clj.zip :as z]))")
      z/root-string)
;; => "(ns nl-test\n  (:require [rewrite-clj.zip :as z]))"

The \r\n line endings have been converted to \n.

Actual behavior
The zipper converts CRLF line endings to LF.

Expected behavior
As per documentation whitespaces should be preserved:

Rewrite-clj is a library that can read, update and write Clojure, ClojureScript and EDN source code while preserving whitespace and comments.

Diagnosis
The CRLF to LF conversion was an intentional workaround as per f78856e:

Handle Windows line endings

While we await https://clojure.atlassian.net/browse/TRDR-65, I've
introduced a work-around.

See rewrite-clj.reader.cljc comments for details.

Fixes https://github.com/clj-commons/rewrite-clj/issues/93

Action
I'm not familiar with the codebase, but I might try to have a look at it at some point.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status

      Low Priority

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions