-
Notifications
You must be signed in to change notification settings - Fork 123
Fix #45: Thread first changes the indentation of the inner forms #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
1dfbc99
65e8156
b400730
e3c2e78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -280,10 +280,22 @@ | |
(or (symbol-matches-key? (fully-qualified-symbol possible-sym context) key) | ||
(symbol-matches-key? (remove-namespace possible-sym) key)))) | ||
|
||
(defn- parent-is-thread-first? [zloc context] | ||
(some #(form-matches-key? zloc % context) #{'-> 'as-> 'some-> 'cond->})) | ||
|
||
(defn- is-first-parameter? [zloc] | ||
(= (z/right (z/leftmost zloc)) zloc)) | ||
lambdank marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
(defn- adjust-idx [zloc idx context] | ||
(cond-> idx | ||
(and (parent-is-thread-first? zloc context) (not (is-first-parameter? zloc))) | ||
(some-> dec (max 0)))) | ||
|
||
|
||
(defn- inner-indent [zloc key depth idx context] | ||
(let [top (nth (iterate z/up zloc) depth)] | ||
(let [top (nth (iterate z/up zloc) depth) | ||
adjusted-idx (adjust-idx (z/up zloc) idx context)] | ||
(when (and (form-matches-key? top key context) | ||
(or (nil? idx) (index-matches-top-argument? zloc depth idx))) | ||
(or (nil? idx) (index-matches-top-argument? zloc depth adjusted-idx))) | ||
(let [zup (z/up zloc)] | ||
(+ (margin zup) (indent-width zup)))))) | ||
|
||
|
@@ -302,9 +314,10 @@ | |
|
||
(defn- block-indent [zloc key idx context] | ||
(when (form-matches-key? zloc key context) | ||
(let [zloc-after-idx (some-> zloc (nth-form (inc idx)))] | ||
(let [adjusted-idx (adjust-idx (z/up zloc) idx context) | ||
zloc-after-idx (some-> zloc (nth-form (inc adjusted-idx)))] | ||
(if (and (or (nil? zloc-after-idx) (first-form-in-line? zloc-after-idx)) | ||
(> (index-of zloc) idx)) | ||
(> (index-of zloc) adjusted-idx)) | ||
(inner-indent zloc key 0 nil context) | ||
(list-indent zloc context))))) | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.