Skip to content

Commit

Permalink
Fix thread-first overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkam2 authored and cespare committed Sep 17, 2021
1 parent 67936d1 commit 5932ea3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions cljfmt/cljfmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func (c *config) processFile(filename string, in io.Reader) error {
p := format.NewPrinter(&buf2)
p.IndentChar = ' '
p.IndentOverrides = c.indentOverrides
p.ThreadFirstStyleOverrides = c.threadFirstOverrides
p.Transforms = c.transforms
if err := p.PrintTree(t); err != nil {
return err
Expand Down
10 changes: 10 additions & 0 deletions format/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ func TestIssue41(t *testing.T) {
testChangeCustom(t, file, file, f)
}

func TestThreadFirstOverride(t *testing.T) {
const file = "custom/threadfirst.clj"
f := func(p *Printer) {
p.ThreadFirstStyleOverrides = map[string]ThreadFirstStyle{
"-?>": ThreadFirstNormal,
}
}
testChangeCustom(t, file, file, f)
}

func testFixture(t *testing.T, filename string) {
testChange(t, filename, filename)
}
Expand Down
8 changes: 8 additions & 0 deletions format/testdata/custom/threadfirst.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(-?> a
b
(cond->
"1"
(foo 1)
"2"
(foo 2)
:default))

0 comments on commit 5932ea3

Please sign in to comment.