Skip to content
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

Formatting proposal: Ensure empty line between method definitions #461

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/syntax_tree/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9981,6 +9981,11 @@ def format(q)
q.breakable_force
q.breakable_force
q.format(statement)
elsif statement.is_a?(DefNode) && previous.is_a?(DefNode) &&
(statement.location.start_line - line) == 1
q.breakable_force
q.breakable_force
q.format(statement)
elsif statement.location.start_line != line
q.breakable_force
q.format(statement)
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,14 @@ def foo( # comment
=end
a
end
%
def foo
end
def bar
end
-
def foo
end

def bar
end
11 changes: 11 additions & 0 deletions test/fixtures/defs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,14 @@ def foo::foo
-
def foo.foo
end
%
def foo.foo
end
def foo.bar
end
-
def foo.foo
end

def foo.bar
end
Loading