Hello everybody, hello Alex,

I noticed that when using `columnar` that changes to the format state get swallowed. Digging into this, it's due to the copying of the state before creating partial output from the following lines (fmt-column.scm, l. 82f):

               ;; gen threads through it's own state, ignore result
               (gen (fmt-set-writer! (copy-fmt-state st) output*))

All of the changes to `st` within the gen function will then ignored. Now I am not exactly sure which changes we want to preserve, but I believe that at least the `properties` should be kept, as they might contain meaningful information (which is how I discovered this bug). Would it make sense to preserve more information from the copied state or should we leave it at that? Currently my fix (also attached) looks like:

       ;; gen threads through it's own state, copy over properties
       (let ([st (gen (fmt-set-writer! (copy-fmt-state st) output*))])
         (fmt-set-properties! orig-st (fmt-properties st)))


Let me know what you think, would be happy to see this included.

Cheers
Nik
diff --git a/fmt/0.8.14/fmt-column.scm b/fmt/0.8.14/fmt-column.scm
index 152bc3c..dd1f18b 100644
--- a/fmt/0.8.14/fmt-column.scm
+++ b/fmt/0.8.14/fmt-column.scm
@@ -79,8 +79,9 @@
                        (set! acc (cons (substring/shared str i) acc))))))
                  ;; update - don't output or the string port will fill up
                  (fmt-update str st))
-               ;; gen threads through it's own state, ignore result
-               (gen (fmt-set-writer! (copy-fmt-state st) output*))
+               ;; gen threads through it's own state, copy over properties
+               (let ([st (gen (fmt-set-writer! (copy-fmt-state st) output*))])
+                 (fmt-set-properties! orig-st (fmt-properties st)))
                ;; reduce # of remaining finite columns
                (set! remaining (- remaining 1))
                ;; write any remaining accumulated output

Reply via email to