Skip to content

Commit d22dfc2

Browse files
authored
Merge pull request #341 from ruby-formatter/fix-331
Fix #331
2 parents 374c3e7 + 30d5d87 commit d22dfc2

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

lib/rufo/formatter.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2147,10 +2147,11 @@ def visit_params(node)
21472147
# [:@label, "b:", [1, 20]]
21482148
write label[1]
21492149
next_token
2150-
skip_space_or_newline
21512150
if value
21522151
consume_space
21532152
visit value
2153+
else
2154+
skip_space
21542155
end
21552156
end
21562157
needs_comma = true
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#~# ORIGINAL issue_331
2+
#~# parens_in_def: :dynamic
3+
class User
4+
def self.by_uid uid:
5+
joins(:authentications).where(authentications: { uid: }).first
6+
end
7+
end
8+
9+
#~# EXPECTED
10+
class User
11+
def self.by_uid uid:
12+
joins(:authentications).where(authentications: { uid: }).first
13+
end
14+
end

spec/lib/rufo/formatter_source_specs/method_definition.rb.spec

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,13 @@ end
371371
def foo(a, ...)
372372
p(...)
373373
end
374+
375+
#~# ORIGINAL issue_331
376+
def foo a:
377+
a
378+
end
379+
380+
#~# EXPECTED
381+
def foo(a:)
382+
a
383+
end

0 commit comments

Comments
 (0)