Skip to content

Commit

Permalink
Merge branch dev into published
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Sep 28, 2024
2 parents cfac062 + 28351dd commit 335af4e
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changes to Calva.

## [Unreleased]

## [2.0.476] - 2024-09-28

- Fix: [Formatting and some pretty printing croaks on new Clojure 1.12.0 syntax](https://github.com/BetterThanTomorrow/calva/issues/2637)

## [2.0.475] - 2024-09-24

- Fix: [Can't start REPL in lein projects with backtick on project.clj](https://github.com/BetterThanTomorrow/calva/issues/2633)
Expand Down
12 changes: 8 additions & 4 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{:deps {zprint/zprint {:mvn/version "1.2.9"}
dev.weavejester/cljfmt {:mvn/version "0.12.0"}
thheller/shadow-cljs {:mvn/version "2.25.2"}
org.clojars.liverm0r/dartclojure {:mvn/version "0.2.22-SNAPSHOT"}
{:deps {org.clojure/clojure {:mvn/version "1.12.0"}
rewrite-clj/rewrite-clj {:mvn/version "1.1.48"} ;; Temporary, while waiting for cljfmt and zprint to bump their deps
zprint/zprint {:mvn/version "1.2.9"
:exclusions [rewrite-clj/rewrite-clj]}
dev.weavejester/cljfmt {:mvn/version "0.12.0"
:exclusions [rewrite-clj/rewrite-clj]}
thheller/shadow-cljs {:mvn/version "2.28.15"}
org.clojars.liverm0r/dartclojure {:mvn/version "0.2.23-SNAPSHOT"}
vvvvalvalval/supdate {:mvn/version "0.2.3"}
camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"}
#_#_org.clojars.liverm0r/dartclojure {:local/root "../DartClojure"}}
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Calva: Clojure & ClojureScript Interactive Programming",
"description": "Integrated REPL, formatter, Paredit, and more. Powered by cider-nrepl and clojure-lsp.",
"icon": "assets/calva.png",
"version": "2.0.475",
"version": "2.0.476",
"publisher": "betterthantomorrow",
"author": {
"name": "Better Than Tomorrow",
Expand Down Expand Up @@ -3391,7 +3391,7 @@
"prettier": "2.5.1",
"rimraf": "^2.7.1",
"screenshot-desktop": "^1.15.0",
"shadow-cljs": "^2.25.2",
"shadow-cljs": "^2.28.15",
"source-map-support": "^0.5.16",
"ts-loader": "^8.0.18",
"ts-node": "^10.3.0",
Expand Down
8 changes: 7 additions & 1 deletion src/cljs-lib/src/calva/fmt/formatter.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@
:indents {"foo" [["inner" 0]]}
:remove-trailing-whitespace? false
:remove-consecutive-blank-lines? false
:align-associative? true}}}))
:align-associative? true}}})

(format-text
{:range-text "^[Long] foo"})

(format-text
{:range-text "^Long/1 foo"}))

(defn extract-range-text
[{:keys [all-text range]}]
Expand Down
6 changes: 6 additions & 0 deletions src/cljs-lib/src/calva/pprint/printer.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,10 @@

(:value (pretty-print struct {:max-length 3}))
;; => "(let [r :r\n this-page :this-page]\n [:div.grid-x.grid-margin-x.grid-margin-y\n [:div.cell.align-center.margin-top.show-for-medium\n [:a#foo.button {:href \"#how-it-works\"} [\"Works\"]]\n [:a#bar.button {:on-click (fn* [] (citrus/broadcast! r :submit ...))}\n \"Send\"]]])"

(pretty-print "^[Long] foo" {})
;;=> {:value "^[Long] foo"}

(pretty-print "^Long/1 foo" {})
;;=> {:value "^Long/1 foo", :error "Pretty print failed. (Invalid symbol: Long/1.)"}
)
6 changes: 5 additions & 1 deletion src/cljs-lib/test/calva/fmt/formatter_test.cljs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
(ns calva.fmt.formatter-test
(:require [calva.fmt.formatter :as sut]
[cljfmt.core :as cljfmt :refer [includes?]]
[cljs.test :include-macros true :refer [deftest is testing]]))

(deftest format-text-at-range
(is (= "(foo)\n(defn bar\n [x]\n baz)"
(:range-text (sut/format-text-at-range {:eol "\n" :all-text " (foo)\n(defn bar\n[x]\nbaz)" :range [2 26]}))))
(is (not (contains? (sut/format-text-at-range {:eol "\n" :all-text " (foo)\n(defn bar\n[x]\nbaz)" :range [2 26]}) :new-index))))

(deftest clojure-1-12-syntax
(is (= {:all-text "^Long/1 a", :range [1 10], :range-tail "Long/1 a", :range-text "Long/1 a"}
(sut/format-text-at-range {:all-text "^Long/1 a" :range [1 10]})))
(is (nil? (:error (sut/format-text-at-range {:all-text "^Long/1 a" :range [1 10]})))))

(def all-text " (foo)
(defn bar
[x]
Expand Down
8 changes: 7 additions & 1 deletion src/cljs-lib/test/calva/pprint/printer_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@
(pretty-print "{:a 1, :b 1 :c 1}" nil))))
(testing "Can opt out of added commas in maps"
(is (= {:value "{:a 1 :b 1 :c 1}"}
(pretty-print "{:a 1, :b 1 :c 1}" {:map {:comma? false}})))))))
(pretty-print "{:a 1, :b 1 :c 1}" {:map {:comma? false}})))))))

(deftest clojure-1-12-syntax
(testing "Valid EDN"
(is (= {:value "^Long/1 a"}
(pretty-print "^Long/1 a" nil)))
(is (nil? (:error (pretty-print "^Long/1 a" nil))))))

0 comments on commit 335af4e

Please sign in to comment.