Skip to content

Commit

Permalink
move edn-limit to only print a str
Browse files Browse the repository at this point in the history
[true, "actual-edn"] is just way too much overhead
now "1,actual-edn" instead.
  • Loading branch information
thheller committed May 7, 2024
1 parent 1b5c489 commit 47a197c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/main/shadow/cljs/ui/components/inspect.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns shadow.cljs.ui.components.inspect
(:require
[clojure.string :as str]
[goog.math :as math]
[shadow.dom :as dom]
[shadow.arborist :as sa]
Expand All @@ -24,11 +25,10 @@
(<< [:svg {:width "24" :height "24" :viewBox "0 0 24 24" :fill "none" :xmlns "http://www.w3.org/2000/svg"}
[:path {:d "M15 19L8 12L15 5" :stroke "#4A5568" :stroke-width "2" :stroke-linecap "round" :stroke-linejoin "round"}]]))

(defn render-edn-limit [[limit-reached text]]
(if limit-reached
(str text " ...")

text))
(defn render-edn-limit [text]
(if (str/starts-with? text "1,")
(str (subs text 2) " ...")
(subs text 2)))

(defc ui-object-as-text [ident attr active?]
(bind data
Expand Down
2 changes: 1 addition & 1 deletion src/main/shadow/remote/runtime/obj_support.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
(str "Execution error:\n"
;; can be any object, really no hope in making this any kind of readable
;; capping it so throwing something large doesn't blow up the REPL
" " (second (lw/pr-str-limit ex 200)) "\n"
" " (subs (lw/pr-str-limit ex 200) 2) "\n"
"\n"))

:clj
Expand Down
4 changes: 2 additions & 2 deletions src/main/shadow/remote/runtime/writer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
(try
(binding [*out* lw]
(pr obj))
[false (.getString lw)]
(str "0," (.getString lw))
(catch LimitWriter$LimitReachedException e
[true (.getString lw)]))))
(str "1," (.getString lw))))))

(defn limit-writer [limit]
(LimitWriter. limit))
Expand Down
12 changes: 6 additions & 6 deletions src/main/shadow/remote/runtime/writer.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
writer (LimitWriter. sb limit)]
(try
(pr-writer obj writer (pr-opts))
[false (.toString sb)]
(str "0," (.toString sb))
(catch :default e
(if-not (keyword-identical? ::limit-reached (:tag (ex-data e)))
(throw e)
[true
(let [s (.toString sb)]
(if (> (.-length s) limit)
(subs s 0 limit)
s))])))))
(str "1,"
(let [s (.toString sb)]
(if (> (.-length s) limit)
(subs s 0 limit)
s))))))))

(defn limit-writer [limit]
(let [sb (StringBuffer.)]
Expand Down

0 comments on commit 47a197c

Please sign in to comment.