diff options
author | Tom Faulhaber <git_com@infolace.com> | 2010-11-03 18:29:43 -0700 |
---|---|---|
committer | Stuart Halloway <stu@thinkrelevance.com> | 2010-12-17 17:08:46 -0500 |
commit | 62128f741d3af4ef5a8700a5ac68ca9010bb1610 (patch) | |
tree | 77b029b71e6ad1a2d1177799045e829aca6674cc | |
parent | 7f303fc06b5e1d925a2fecef54b2597410c47111 (diff) |
Make sure we write saved trailing white space ahead of a multiline string output.
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
-rw-r--r-- | src/clj/clojure/pprint/pretty_writer.clj | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/clj/clojure/pprint/pretty_writer.clj b/src/clj/clojure/pprint/pretty_writer.clj index 438a9cb5..551e668a 100644 --- a/src/clj/clojure/pprint/pretty_writer.clj +++ b/src/clj/clojure/pprint/pretty_writer.clj @@ -310,6 +310,13 @@ (write-tokens this buf true) (setf :buffer [])))) +(defn- write-white-space [^Writer this] + (when-let [^String tws (getf :trailing-white-space)] + ; (prlabel wws (str "*" tws "*")) + (.write (getf :base) tws) + (dosync + (setf :trailing-white-space nil)))) + ;;; If there are newlines in the string, print the lines up until the last newline, ;;; making the appropriate adjustments. Return the remainder of the string (defn- write-initial-lines @@ -326,7 +333,9 @@ (setf :pos newpos) (add-to-buffer this (make-buffer-blob l nil oldpos newpos)) (write-buffered-output this)) - (.write (getf :base) l)) + (do + (write-white-space this) + (.write (getf :base) l))) (.write (getf :base) (int \newline)) (doseq [^String l (next (butlast lines))] (.write (getf :base) l) @@ -337,12 +346,6 @@ (last lines)))))) -(defn- write-white-space [^Writer this] - (if-let [^String tws (getf :trailing-white-space)] - (dosync - (.write (getf :base) tws) - (setf :trailing-white-space nil)))) - (defn- p-write-char [^Writer this ^Integer c] (if (= (getf :mode) :writing) (do |