From 203968960e995ac48fb34cbad7e647862cd671c4 Mon Sep 17 00:00:00 2001 From: CrossNox Date: Tue, 29 Nov 2022 17:07:25 -0300 Subject: [PATCH] fix listar code --- src/rustint/core.clj | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/rustint/core.clj b/src/rustint/core.clj index 70a5898..205fecf 100644 --- a/src/rustint/core.clj +++ b/src/rustint/core.clj @@ -2125,14 +2125,23 @@ (defn flistar [ilevel t nxt] (let [ - preceding_space (clojure.string/join (repeat (* ilevel 2) " ")), - bracket_prec_space (clojure.string/join (repeat (* (- ilevel 1) 2) " ")) + preceding_space (clojure.string/join (repeat ilevel " ")), + bracket_prec_space (clojure.string/join (repeat (- ilevel 1) " ")) ] (cond - (string? t) (format "\"%s\" " t) + (string? t) (format "\"%s\" " (clojure.string/escape t char-escape-string)) (= t (symbol "{")) (format "\n%s{\n%s" bracket_prec_space preceding_space) - (= t (symbol "}")) (format "\n%s}" bracket_prec_space) - (= t (symbol ";")) (format ";\n%s" preceding_space) + (= t (symbol "}")) ( + cond + (nil? nxt) (format "\n%s}\n" preceding_space) + (not= nxt (symbol "}")) (format "\n%s}\n%s" preceding_space preceding_space) + (= nxt (symbol "}")) (format "\n%s}" preceding_space) + ) + (= t (symbol ";")) ( + cond + (= nxt (symbol "}")) ";" + :else (format ";\n%s" preceding_space) + ) (and (not= nxt (symbol "{")) (not= nxt (symbol "}"))) (format "%s " t) :else (format "%s" t) )